abi-compliance-checker.pl revision 3ad495d27a8b114627d03abbe369b5b68d10fa62
1ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#!/usr/bin/perl
2ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
33ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko# ABI Compliance Checker (ABICC) 1.99.19
41bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# A tool for checking backward compatibility of a C/C++ library API
5ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
6850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2009-2011 Institute for System Programming, RAS
7850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies)
88bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko# Copyright (C) 2011-2012 ROSA Laboratory
9e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko# Copyright (C) 2012-2016 Andrey Ponomarenko's ABI Laboratory
10ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
11ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Written by Andrey Ponomarenko
12ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
13ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# PLATFORMS
14ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# =========
15ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Linux, FreeBSD, Mac OS X, Haiku, MS Windows, Symbian
16ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
17ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# REQUIREMENTS
18ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# ============
19ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Linux
20c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - G++ (3.0-4.7, 4.8.3, 4.9 or newer)
21ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - GNU Binutils (readelf, c++filt, objdump)
22850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Perl 5 (5.8 or newer)
23f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
248a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko#    - ABI Dumper (0.99.15 or newer)
25ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
26ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Mac OS X
27570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko#    - Xcode (g++, c++filt, otool, nm)
28f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
29ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
30ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  MS Windows
31c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - MinGW (3.0-4.7, 4.8.3, 4.9 or newer)
32ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - MS Visual C++ (dumpbin, undname, cl)
33850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Active Perl 5 (5.8 or newer)
34ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Sigcheck v1.71 or newer
35ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Info-ZIP 3.0 (zip, unzip)
36f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
3774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#    - Add tool locations to the PATH environment variable
38ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Run vsvars32.bat (C:\Microsoft Visual Studio 9.0\Common7\Tools\)
39ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
40ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is free software: you can redistribute it and/or modify
41ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# it under the terms of the GNU General Public License or the GNU Lesser
42ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# General Public License as published by the Free Software Foundation.
43ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
44ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is distributed in the hope that it will be useful,
45ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# but WITHOUT ANY WARRANTY; without even the implied warranty of
46ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
47ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# GNU General Public License for more details.
48ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
49ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# You should have received a copy of the GNU General Public License
50ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# and the GNU Lesser General Public License along with this program.
51ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# If not, see <http://www.gnu.org/licenses/>.
52ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
53ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Getopt::Long;
54ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetopt::Long::Configure ("posix_default", "no_ignore_case");
55ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Path qw(mkpath rmtree);
56ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Temp qw(tempdir);
57ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Copy qw(copy move);
5874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkouse Cwd qw(abs_path cwd realpath);
59177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkouse Storable qw(dclone);
60ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Data::Dumper;
612fba63087b6e973c04b6d235fe10363657985263Andrey Ponomarenkouse Config;
62ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
633ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenkomy $TOOL_VERSION = "1.99.19";
64177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ABI_DUMP_VERSION = "3.2";
65d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenkomy $XML_REPORT_VERSION = "1.2";
66f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy $XML_ABI_DUMP_VERSION = "1.2";
67ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OSgroup = get_OSgroup();
68ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ORIG_DIR = cwd();
69ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TMP_DIR = tempdir(CLEANUP=>1);
706fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenkomy $LOCALE = "C.UTF-8";
71ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
72ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Internal modules
73ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MODULES_DIR = get_Modules();
74ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkopush(@INC, get_dirname($MODULES_DIR));
75ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Rules DB
76ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RULES_PATH = (
77ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Binary" => $MODULES_DIR."/RulesBin.xml",
78ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Source" => $MODULES_DIR."/RulesSrc.xml");
79ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8014b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenkomy ($Help, $ShowVersion, %Descriptor, $TargetLibraryName,
81ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TestTool, $DumpAPI, $SymbolsListPath, $CheckHeadersOnly_Opt, $UseDumps,
82ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko$AppPath, $StrictCompat, $DumpVersion, $ParamNamesPath,
8314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko%RelativeDirectory, $TargetTitle, $TestDump, $LoggingPath,
846ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko%TargetVersion, $InfoMsg, $CrossGcc, %OutputLogPath,
85ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$OutputReportPath, $OutputDumpPath, $ShowRetVal, $SystemRoot_Opt, $DumpSystem,
86ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$CmpSystems, $TargetLibsPath, $Debug, $CrossPrefix, $UseStaticLibs, $NoStdInc,
87ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TargetComponent_Opt, $TargetSysInfo, $TargetHeader, $ExtendedCheck, $Quiet,
8807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko$SkipHeadersPath, $CppCompat, $LogMode, $StdOut, $ListAffected, $ReportFormat,
891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko$UserLang, $TargetHeadersPath, $BinaryOnly, $SourceOnly, $BinaryReportPath,
9052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko$SourceReportPath, $UseXML, $SortDump, $DumpFormat,
91177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko$ExtraInfo, $ExtraDump, $Force, $Tolerance, $Tolerant, $SkipSymbolsListPath,
921fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko$CheckInfo, $Quick, $AffectLimit, $AllAffected, $CppIncompat,
931fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko$SkipInternalSymbols, $SkipInternalTypes, $TargetArch, $GccOptions,
94e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko$TypesListPath, $SkipTypesListPath, $CheckPrivateABI);
95ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
96ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CmdName = get_filename($0);
97ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_LibExt = (
98ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic" => {
999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"so",
100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "macos"=>"dylib",
101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"dll",
1029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"dso",
1039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"so"
104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static" => {
1069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"a",
107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"lib",
1089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"lib",
1099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"a"
110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_Archive = (
114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"zip",
115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"tar.gz"
116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ERROR_CODE = (
119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Compatible verdict
120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compatible"=>0,
121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Success"=>0,
122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible verdict
123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Incompatible"=>1,
124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Undifferentiated error code
125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Error"=>2,
126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # System command is not found
127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Not_Found"=>3,
128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot access input files
129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Access_Error"=>4,
130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot compile header files
131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Cannot_Compile"=>5,
132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Header compiled with errors
133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compile_Error"=>6,
134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Invalid input ABI dump
135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Invalid_Dump"=>7,
136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible version of ABI dump
137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Dump_Version"=>8,
138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot find a module
139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Module_Error"=>9,
140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty intersection between
141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # headers and shared objects
142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Intersection"=>10,
143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty set of symbols in headers
144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Set"=>11
145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
147ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkomy $HomePage = "http://lvc.github.io/abi-compliance-checker/";
148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
149b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenkomy $ShortUsage = "ABI Compliance Checker (ABICC) $TOOL_VERSION
1501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey PonomarenkoA tool for checking backward compatibility of a C/C++ library API
15152b2e35f3dfda9369631beeb5d5480df65c47950Andrey PonomarenkoCopyright (C) 2015 Andrey Ponomarenko's ABI Laboratory
152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoLicense: GNU LGPL or GNU GPL
153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUsage: $CmdName [options]
155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey PonomarenkoExample: $CmdName -lib NAME -old OLD.xml -new NEW.xml
156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOLD.xml and NEW.xml are XML-descriptors:
158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/headers/
165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/libraries/
169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMore info: $CmdName --help\n";
172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
173570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkoif($#ARGV==-1)
174570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $ShortUsage);
176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit(0);
177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetOptions("h|help!" => \$Help,
180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "i|info!" => \$InfoMsg,
181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v|version!" => \$ShowVersion,
182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dumpversion!" => \$DumpVersion,
183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# general options
184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l|lib|library=s" => \$TargetLibraryName,
185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d1|old|o=s" => \$Descriptor{1}{"Path"},
186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d2|new|n=s" => \$Descriptor{2}{"Path"},
187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump|dump-abi|dump_abi=s" => \$DumpAPI,
188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# extra options
189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "app|application=s" => \$AppPath,
190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "static-libs!" => \$UseStaticLibs,
191d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-path|cross-gcc=s" => \$CrossGcc,
192d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-prefix|cross-prefix=s" => \$CrossPrefix,
193d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-options=s" => \$GccOptions,
194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysroot=s" => \$SystemRoot_Opt,
19515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko  "v1|vnum1|version1|vnum=s" => \$TargetVersion{1},
19615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko  "v2|vnum2|version2=s" => \$TargetVersion{2},
197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "s|strict!" => \$StrictCompat,
198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "symbols-list=s" => \$SymbolsListPath,
19952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  "types-list=s" => \$TypesListPath,
200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "skip-symbols=s" => \$SkipSymbolsListPath,
20199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko  "skip-types=s" => \$SkipTypesListPath,
202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "headers-list=s" => \$TargetHeadersPath,
203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "skip-headers=s" => \$SkipHeadersPath,
204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "header=s" => \$TargetHeader,
205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "headers-only|headers_only!" => \$CheckHeadersOnly_Opt,
206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "show-retval!" => \$ShowRetVal,
207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "use-dumps!" => \$UseDumps,
208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "nostdinc!" => \$NoStdInc,
209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-system=s" => \$DumpSystem,
210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysinfo=s" => \$TargetSysInfo,
211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "cmp-systems!" => \$CmpSystems,
212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "libs-list=s" => \$TargetLibsPath,
213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "ext|extended!" => \$ExtendedCheck,
214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "q|quiet!" => \$Quiet,
215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "stdout!" => \$StdOut,
216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-format=s" => \$ReportFormat,
2175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko  "dump-format=s" => \$DumpFormat,
2181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "xml!" => \$UseXML,
219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "lang=s" => \$UserLang,
22054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  "arch=s" => \$TargetArch,
2211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "binary|bin|abi!" => \$BinaryOnly,
2221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "source|src|api!" => \$SourceOnly,
2232489ef88760861175102e4508089608391beead3Andrey Ponomarenko  "limit-affected|affected-limit=s" => \$AffectLimit,
224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# other options
225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test!" => \$TestTool,
226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test-dump!" => \$TestDump,
227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "debug!" => \$Debug,
22807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "cpp-compatible!" => \$CppCompat,
2292b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  "cpp-incompatible!" => \$CppIncompat,
230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "p|params=s" => \$ParamNamesPath,
231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath1|relpath=s" => \$RelativeDirectory{1},
232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath2=s" => \$RelativeDirectory{2},
233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-path=s" => \$OutputDumpPath,
23462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "sort!" => \$SortDump,
235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-path=s" => \$OutputReportPath,
2361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "bin-report-path=s" => \$BinaryReportPath,
2371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "src-report-path=s" => \$SourceReportPath,
238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log-path=s" => \$LoggingPath,
239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log1-path=s" => \$OutputLogPath{1},
240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log2-path=s" => \$OutputLogPath{2},
241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "logging-mode=s" => \$LogMode,
242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "list-affected!" => \$ListAffected,
24314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  "title|l-full|lib-full=s" => \$TargetTitle,
2441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "component=s" => \$TargetComponent_Opt,
245570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-info=s" => \$ExtraInfo,
246570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-dump!" => \$ExtraDump,
2478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "force!" => \$Force,
2488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "tolerance=s" => \$Tolerance,
249177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "tolerant!" => \$Tolerant,
250e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "check!" => \$CheckInfo,
251f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko  "quick!" => \$Quick,
252d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko  "all-affected!" => \$AllAffected,
2531fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  "skip-internal-symbols|skip-internal=s" => \$SkipInternalSymbols,
2541fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  "skip-internal-types=s" => \$SkipInternalTypes,
255e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko  "check-private-abi!" => \$CheckPrivateABI
256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko) or ERR_MESSAGE();
257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ERR_MESSAGE()
259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "\n".$ShortUsage);
261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{"Error"});
262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_TYPE = $UseStaticLibs?"static":"dynamic";
265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLIB_TYPE = $LIB_TYPE;
266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoif($OSgroup!~/macos|windows/ and $SLIB_TYPE eq "dynamic")
267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # show as "shared" library
268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SLIB_TYPE = "shared";
269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_EXT = getLIB_EXT($OSgroup);
271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $AR_EXT = getAR_EXT($OSgroup);
272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $BYTE_SIZE = 8;
273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMMON_LOG_PATH = "logs/run.log";
274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HelpMessage="
276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoNAME:
277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  ABI Compliance Checker ($CmdName)
2780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  Check backward compatibility of a C/C++ library API
279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoDESCRIPTION:
281b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko  ABI Compliance Checker (ABICC) is a tool for checking backward binary and
2821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  source-level compatibility of a $SLIB_TYPE C/C++ library. The tool checks
2831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  header files and $SLIB_TYPE libraries (*.$LIB_EXT) of old and new versions and
2841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  analyzes changes in API and ABI (ABI=API+compiler ABI) that may break binary
2851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  and/or source-level compatibility: changes in calling stack, v-table changes,
2861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  removed symbols, renamed fields, etc. Binary incompatibility may result in
2871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  crashing or incorrect behavior of applications built with an old version of
2881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  a library if they run on a new one. Source incompatibility may result in
2891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  recompilation errors with a new library version.
290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
291dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  The tool is intended for developers of software libraries and maintainers
292dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  of operating systems who are interested in ensuring backward compatibility,
293dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  i.e. allow old applications to run or to be recompiled with newer library
294dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  versions.
295dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
296dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  Also the tool can be used by ISVs for checking applications portability to
297dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  new library versions. Found issues can be taken into account when adapting
298dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  the application to a new library version.
299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  This tool is free software: you can redistribute it and/or modify it
301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  under the terms of the GNU LGPL or GNU GPL.
302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUSAGE:
304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  $CmdName [options]
305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXAMPLE:
3070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  $CmdName -lib NAME -old OLD.xml -new NEW.xml
308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  OLD.xml and NEW.xml are XML-descriptors:
310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/header(s)/
317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/header(s)/
318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/library(ies)/
323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/library(ies)/
324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoINFORMATION OPTIONS:
328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -h|-help
329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print this help.
330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -i|-info
332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print complete info.
333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -v|-version
335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print version information.
336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -dumpversion
338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print the tool version ($TOOL_VERSION) and don't do anything else.
339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGENERAL OPTIONS:
34107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l|-lib|-library NAME
342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Library name (without version).
343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d1|-old|-o PATH
345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 1st (old) library version.
346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      It may be one of the following:
347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         1. XML-descriptor (VERSION.xml file):
349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <version>
351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  1.0
352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </version>
353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <headers>
355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/header(s)/
356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/header(s)/
357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </headers>
359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <libs>
361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/library(ies)/
362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/library(ies)/
363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </libs>
365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
36601e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko                 ...
367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         2. ABI dump generated by -dump option
369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         3. Directory with headers and/or $SLIB_TYPE libraries
370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         4. Single header file
371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
37201e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko      If you are using an 2-4 descriptor types then you should
373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      specify version numbers with -v1 and -v2 options too.
374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      For more information, please see:
3761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        http://ispras.linuxbase.org/index.php/Library_Descriptor
377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
37807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d2|-new|-n PATH
379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 2nd (new) library version.
380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
38107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump|-dump-abi PATH
382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create library ABI dump for the input XML descriptor. You can
383570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      transfer it anywhere and pass instead of the descriptor. Also
384570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      it can be used for debugging the tool.
385570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
3866ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko      Supported versions of ABI dump: 2.0<=V<=$ABI_DUMP_VERSION\n";
387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub HELP_MESSAGE() {
389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $HelpMessage."
390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFO:
391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko     $CmdName --info\n");
392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub INFO_MESSAGE()
395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "$HelpMessage
397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXTRA OPTIONS:
39807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -app|-application PATH
39952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify the application that should be checked
400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for portability to the new library version.
401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -static-libs
403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check static libraries instead of the shared ones. The <libs> section
404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the XML-descriptor should point to static libraries location.
405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4068bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-path PATH
407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to the cross GCC compiler to use instead of the usual (host) GCC.
408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4098bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-prefix PREFIX
410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      GCC toolchain prefix.
4118bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko
4128bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko  -gcc-options OPTS
4138bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko      Additional compiler options.
414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
41507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysroot DIR
416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify the alternative root directory. The tool will search for include
41707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      paths in the DIR/usr/include and DIR/usr/lib directories.
418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
41907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v1|-version1 NUM
420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 1st library version outside the descriptor. This option is needed
421bd1767ac0e8d4a913683bf84e6305bed1850a427Mathieu Malaterre      if you have preferred an alternative descriptor type (see -d1 option).
422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      In general case you should specify it in the XML-descriptor:
424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <version>
425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              VERSION
426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </version>
427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v2|-version2 NUM
429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 2nd library version outside the descriptor.
430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
431c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko  -vnum NUM
432c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko      Specify the library version in the generated ABI dump. The <version> section
433c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko      of the input XML descriptor will be overwritten in this case.
434c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko
435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -s|-strict
436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Treat all compatibility warnings as problems. Add a number of \"Low\"
437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      severity problems to the return value of the tool.
438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -headers-only
440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check header files without $SLIB_TYPE libraries. It is easy to run, but may
441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without detecting of added/removed symbols.
443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <libs> section
445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -show-retval
451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Show the symbol's return type in the report.
452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
45307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -symbols-list PATH
45452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify a file with a list of symbols (mangled
45552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      names in C++) that should be checked. Other symbols will not be checked.
45652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
45752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  -types-list PATH
45852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option allows to specify a file with a list of types that should
45952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      be checked. Other types will not be checked.
460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -skip-symbols PATH
46299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko      The list of symbols that should not be checked.
46399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
46499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko  -skip-types PATH
46599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko      The list of types that should not be checked.
466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -headers-list PATH
468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The file with a list of headers, that should be checked/dumped.
469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
47007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -skip-headers PATH
471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with the list of header files, that should not be checked.
472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -header NAME
474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Check/Dump ABI of this header only.
475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -use-dumps
477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Make dumps for two versions of a library and compare dumps. This should
478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      increase the performance of the tool and decrease the system memory usage.
479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -nostdinc
481570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Do not search in GCC standard system directories for header files.
482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system NAME -sysroot DIR
48407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Find all the shared libraries and header files in DIR directory,
485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      create XML descriptors and make ABI dumps for each library. The result
486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      set of ABI dumps can be compared (--cmp-systems) with the other one
487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      created for other version of operating system in order to check them for
488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      compatibility. Do not forget to specify -cross-gcc option if your target
489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system requires some specific version of GCC compiler (different from
490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the host GCC). The system ABI dump will be generated to:
49107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_dumps/NAME/ARCH
492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system DESCRIPTOR.xml
494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The same as the previous option but takes an XML descriptor of the target
495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system as input, where you should describe it:
496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Primary sections */
498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <name>
500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Name of the system */
501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </name>
502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to header files and/or
505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with header files, one per line */
506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to shared libraries and/or
510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with shared libraries, one per line */
511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Optional sections */
514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_headers>
516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for header files to automatically
518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 generate include paths, one per line */
519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_headers>
520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_libs>
522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for shared libraries to resolve
524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 dependencies, one per line */
525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_libs>
526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <tools>
528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories with tools used
529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for analysis (GCC toolchain), one per line */
530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </tools>
531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <cross_prefix>
533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* GCC toolchain prefix.
534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 Examples:
535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-linux-gnueabi
536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-none-symbianelf */
537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </cross_prefix>
538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <gcc_options>
540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Additional GCC options, one per line */
541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </gcc_options>
542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
54307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysinfo DIR
54452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option should be used with -dump-system option to dump
54552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      ABI of operating systems and configure the dumping process.
54652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      You can find a sample in the package:
547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          modules/Targets/{unix, symbian, windows}
548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
54907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cmp-systems -d1 sys_dumps/NAME1/ARCH -d2 sys_dumps/NAME2/ARCH
550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare two system ABI dumps. Create compatibility reports for each
551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and the common HTML report including the summary of test
552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      results for all checked libraries. Report will be generated to:
55307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_compat_reports/NAME1_to_NAME2/ARCH
554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -libs-list PATH
556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with a list of libraries, that should be dumped by
557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the -dump-system option or should be checked by the -cmp-systems option.
558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -ext|-extended
560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If your library A is supposed to be used by other library B and you
561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      want to control the ABI of B, then you should enable this option. The
562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      tool will check for changes in all data types, even if they are not
563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      used by any function in the library A. Such data types are not part
564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the A library ABI, but may be a part of the ABI of the B library.
565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The short scheme is:
567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        app C (broken) -> lib B (broken ABI) -> lib A (stable ABI)
568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -q|-quiet
570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print all messages to the file instead of stdout and stderr.
571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default path (can be changed by -log-path option):
572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          $COMMON_LOG_PATH
573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -stdout
575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print analysis results (compatibility reports and ABI dumps) to stdout
576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      instead of creating a file. This would allow piping data to other programs.
577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
57807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-format FMT
579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change format of compatibility report.
580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Formats:
581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        htm - HTML format (default)
582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        xml - XML format
583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-format FMT
5855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Change format of ABI dump.
5865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Formats:
5875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        perl - Data::Dumper format (default)
5885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        xml - XML format
5895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
5901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -xml
5915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Alias for: --report-format=xml or --dump-format=xml
5921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
59307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -lang LANG
594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Set library language (C or C++). You can use this option if the tool
595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      cannot auto-detect a language. This option may be useful for checking
596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      C-library headers (--lang=C) in --headers-only or --extended modes.
59754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
59854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  -arch ARCH
59954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      Set library architecture (x86, x86_64, ia64, arm, ppc32, ppc64, s390,
60054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      ect.). The option is useful if the tool cannot detect correct architecture
60154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      of the input objects.
602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -binary|-bin|-abi
6041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Binary\" compatibility problems only.
6051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
60607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
6071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
6081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -source|-src|-api
6091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Source\" compatibility problems only.
6101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
61107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
612f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6132489ef88760861175102e4508089608391beead3Andrey Ponomarenko  -limit-affected LIMIT
614f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      The maximum number of affected symbols listed under the description
615f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      of the changed type in the report.
6161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOTHER OPTIONS:
618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test
619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Run internal tests. Create two binary incompatible versions of a sample
620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and run the tool to check them for compatibility. This option
62152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      allows to check if the tool works correctly in the current environment.
622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test-dump
624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Test ability to create, read and compare ABI dumps.
625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -debug
627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Debugging mode. Print debug info on the screen. Save intermediate
628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      analysis stages in the debug directory:
62907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          debug/LIB_NAME/VERSION/
630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Also consider using --dump option for debugging the tool.
6321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -cpp-compatible
63407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      If your header files are written in C language and can be compiled
63507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      by the G++ compiler (i.e. don't use C++ keywords), then you can tell
63607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      the tool about this and speedup the analysis.
6372b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
6382b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  -cpp-incompatible
6392b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko      Set this option if input C header files use C++ keywords.
640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
64107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -p|-params PATH
642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to file with the function parameter names. It can be used
643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for improving report view if the library header files have no
644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      parameter names. File format:
645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func1;param1;param2;param3 ...
647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func2;param1;param2;param3 ...
648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko             ...
649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath PATH
65107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the XML-descriptor used
652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for dumping the library ABI (see -dump option).
653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath1 PATH
65507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 1st XML-descriptor (-d1).
656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath2 PATH
65807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 2nd XML-descriptor (-d2).
659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-path PATH
6615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Specify a *.abi.$AR_EXT or *.abi file path where to generate an ABI dump.
662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
66307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          abi_dumps/LIB_NAME/LIB_NAME_VERSION.abi.$AR_EXT
664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -sort
66662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Enable sorting of data in ABI dumps.
66762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
66807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-path PATH
6690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      Path to compatibility report.
6701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
67107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/compat_report.html
6721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
67307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -bin-report-path PATH
6741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Binary\" compatibility report.
675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
67607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -src-report-path PATH
6791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Source\" compatibility report.
6801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
68107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
6821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
68307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log-path PATH
684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for all messages.
685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
68607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/VERSION/log.txt
687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log1-path PATH
689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 1st version of a library.
690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V1/log.txt
692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log2-path PATH
694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 2nd version of a library.
695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V2/log.txt
697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -logging-mode MODE
699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change logging mode.
700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Modes:
701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        w - overwrite old logs (default)
702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        a - append old logs
703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        n - do not write any logs
704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -list-affected
706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Generate file with the list of incompatible
707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      symbols beside the HTML compatibility report.
708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Use 'c++filt \@file' command from GNU binutils
709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      to unmangle C++ symbols in the generated file.
7101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default names:
711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          abi_affected.txt
7121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko          src_affected.txt
713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
71407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -component NAME
715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The component name in the title and summary of the HTML report.
716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          library
71852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
71914b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  -title NAME
72007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Change library name in the report title to NAME. By default
721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      will be displayed a name specified by -l option.
72207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
72307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -extra-info DIR
72407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Dump extra info to DIR.
725570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
726570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -extra-dump
727570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create extended ABI dump containing all symbols
728570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      from the translation unit.
729570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
730570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -force
731570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Try to use this option if the tool doesn't work.
7328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerance LEVEL
7348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Apply a set of heuristics to successfully compile input
7358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      header files. You can enable several tolerance levels by
7368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      joining them into one string (e.g. 13, 124, etc.).
7378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Levels:
7388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          1 - skip non-Linux headers (e.g. win32_*.h, etc.)
7398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          2 - skip internal headers (e.g. *_p.h, impl/*.h, etc.)
7408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          3 - skip headers that iclude non-Linux headers
7418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          4 - skip headers included by others
7428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerant
7448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Enable highest tolerance level [1234].
745177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
746177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  -check
747177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      Check completeness of the ABI dump.
748e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
749e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  -quick
750e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko      Quick analysis. Disable check of some template instances.
751d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
7521fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  -skip-internal-symbols PATTERN
7531fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko      Do not check symbols matched by the pattern.
7541fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
7551fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko  -skip-internal-types PATTERN
7561fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko      Do not check types matched by the pattern.
757e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
758e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko  -check-private-abi
759e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      Check data types from the private part of the ABI when
760e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      comparing ABI dumps created by the ABI Dumper tool with
761e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      use of the -public-headers option.
762e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
763e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko      Requires ABI Dumper >= 0.99.14
76462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT:
766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Compatibility report will be generated to:
76707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/compat_report.html
768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Log will be generated to:
77007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V1/log.txt
77107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V2/log.txt
772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXIT CODES:
774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    0 - Compatible. The tool has run without any errors.
775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    non-zero - Incompatible or the tool has run with errors.
776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFORMATION:
778ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    ".$HomePage."\n");
779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Operator_Indication = (
782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not" => "~",
783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assign" => "=",
784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "andassign" => "&=",
785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "orassign" => "|=",
786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xorassign" => "^=",
787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or" => "|",
788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xor" => "^",
789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "addr" => "&",
790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and" => "&",
791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lnot" => "!",
792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "eq" => "==",
793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ne" => "!=",
794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lt" => "<",
795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshift" => "<<",
796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshiftassign" => "<<=",
797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshiftassign" => ">>=",
798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "call" => "()",
799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mod" => "%",
800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "modassign" => "%=",
801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "subs" => "[]",
802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "land" => "&&",
803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lor" => "||",
804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshift" => ">>",
805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ref" => "->",
806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "le" => "<=",
807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "deref" => "*",
808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mult" => "*",
809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "preinc" => "++",
810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => " delete",
811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecnew" => " new[]",
812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecdelete" => " delete[]",
813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "predec" => "--",
814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postinc" => "++",
815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postdec" => "--",
816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plusassign" => "+=",
817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plus" => "+",
818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minus" => "-",
819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minusassign" => "-=",
820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gt" => ">",
821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ge" => ">=",
822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => " new",
823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "multassign" => "*=",
824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "divassign" => "/=",
825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "div" => "/",
826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "neg" => "-",
827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pos" => "+",
828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "memref" => "->*",
829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "compound" => "," );
830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
83162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %UnknownOperator;
83262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
83362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %NodeType= (
83462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "array_type" => "Array",
83562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "binfo" => "Other",
83662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "boolean_type" => "Intrinsic",
83762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "complex_type" => "Intrinsic",
83862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "const_decl" => "Other",
83962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "enumeral_type" => "Enum",
84062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "field_decl" => "Other",
84162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_decl" => "Other",
84262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_type" => "FunctionType",
84362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "identifier_node" => "Other",
84462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_cst" => "Other",
84562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_type" => "Intrinsic",
846177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "vector_type" => "Vector",
84762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "method_type" => "MethodType",
84862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "namespace_decl" => "Other",
84962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "parm_decl" => "Other",
85062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "pointer_type" => "Pointer",
85162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_cst" => "Other",
85262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_type" => "Intrinsic",
85362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "record_type" => "Struct",
85462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "reference_type" => "Ref",
85562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "string_cst" => "Other",
85662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "template_decl" => "Other",
857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "template_type_parm" => "TemplateParam",
858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "typename_type" => "TypeName",
859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "sizeof_expr" => "SizeOf",
86062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_list" => "Other",
86162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_vec" => "Other",
86262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "type_decl" => "Other",
86362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "union_type" => "Union",
86462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "var_decl" => "Other",
86562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "void_type" => "Intrinsic",
8668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "nop_expr" => "Other", #
8678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "addr_expr" => "Other", #
86862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "offset_type" => "Other" );
86962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_C = map {$_=>1} (
871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++ 2003 keywords
872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "public",
873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "protected",
874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "private",
875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default",
876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "template",
877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new",
878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"asm",
879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic_cast",
880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "auto",
881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "try",
882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "namespace",
883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typename",
884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "using",
885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "reinterpret_cast",
886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "friend",
887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "class",
888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "virtual",
889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "const_cast",
890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mutable",
891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_cast",
892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "export",
893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++0x keywords
894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "noexcept",
895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nullptr",
896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "constexpr",
897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_assert",
898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "explicit",
899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # cannot be used as a macro name
900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # as it is an operator in C++
901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and",
902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"and_eq",
903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not",
904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"not_eq",
905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or"
906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"or_eq",
907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitand",
908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitor",
909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor",
910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor_eq",
911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"compl"
912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_F = map {$_=>1} (
915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete",
916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "catch",
917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "alignof",
918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "thread_local",
919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "decltype",
920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typeid"
921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_O = map {$_=>1} (
924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool",
925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "register",
926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inline",
927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "operator"
928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_A = map {$_=>1} (
931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "this",
9328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "throw",
9338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "template"
934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (keys(%CppKeywords_C),
937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_F),
938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_O)) {
939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CppKeywords_A{$_}=1;
940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Header file extensions as described by gcc
943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IntrinsicMangling = (
946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "void" => "v",
947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool" => "b",
948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar_t" => "w",
949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "char" => "c",
950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signed char" => "a",
951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned char" => "h",
952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "short" => "s",
953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned short" => "t",
954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "int" => "i",
955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int" => "j",
956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long" => "l",
957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long" => "m",
958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long" => "x",
959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int64" => "x",
960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long" => "y",
961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int128" => "n",
962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned __int128" => "o",
963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "float" => "f",
964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "double" => "d",
965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long double" => "e",
966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float80" => "e",
967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float128" => "g",
968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "..." => "z"
969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %IntrinsicNames = map {$_=>1} keys(%IntrinsicMangling);
972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdcxxMangling = (
974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std"=>"St",
975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std9allocator"=>"Sa",
976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_string"=>"Sb",
977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_stringIcE"=>"Ss",
978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_istreamIcE"=>"Si",
979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_ostreamIcE"=>"So",
980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std14basic_iostreamIcE"=>"Sd"
981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
983e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkomy $DEFAULT_STD_PARMS = "std::(allocator|less|char_traits|regex_traits|istreambuf_iterator|ostreambuf_iterator)";
984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %DEFAULT_STD_ARGS = map {$_=>1} ("_Alloc", "_Compare", "_Traits", "_Rx_traits", "_InIter", "_OutIter");
985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ADD_TMPL_INSTANCES = 1;
987f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $EMERGENCY_MODE_48 = 0;
98807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffix = (
990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int"=>"u",
991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long"=>"l",
992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long"=>"ul",
993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long"=>"ll",
994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long"=>"ull"
995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffixR =
998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoreverse(%ConstantSuffix);
999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OperatorMangling = (
1001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "~" => "co",
1002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "=" => "aS",
1003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|" => "or",
1004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^" => "eo",
1005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&" => "an",#ad (addr)
1006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "==" => "eq",
1007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!" => "nt",
1008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!=" => "ne",
1009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<" => "lt",
1010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<=" => "le",
1011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<" => "ls",
1012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<=" => "lS",
1013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">" => "gt",
1014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">=" => "ge",
1015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>" => "rs",
1016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>=" => "rS",
1017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "()" => "cl",
1018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%" => "rm",
1019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "[]" => "ix",
1020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&&" => "aa",
1021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "||" => "oo",
1022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*" => "ml",#de (deref)
1023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "++" => "pp",#
1024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "--" => "mm",#
1025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => "nw",
1026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => "dl",
1027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new[]" => "na",
1028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete[]" => "da",
1029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+=" => "pL",
1030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+" => "pl",#ps (pos)
1031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-" => "mi",#ng (neg)
1032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-=" => "mI",
1033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*=" => "mL",
1034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/=" => "dV",
1035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&=" => "aN",
1036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|=" => "oR",
1037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%=" => "rM",
1038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^=" => "eO",
1039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/" => "dv",
1040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->*" => "pm",
1041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->" => "pt",#rf (ref)
1042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "," => "cm",
1043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "?" => "qu",
1044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "." => "dt",
1045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sizeof"=> "sz"#st
1046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Intrinsic_Keywords = map {$_=>1} (
104962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "true",
105062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "false",
105162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Bool",
105262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Complex",
105362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "const",
105462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "int",
105562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "long",
105662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "void",
105762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "short",
105862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "float",
105962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "volatile",
106062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "restrict",
106162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "unsigned",
106262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "signed",
106362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "char",
106462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "double",
106562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "class",
106662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "struct",
106762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "union",
106862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "enum"
106962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko);
107062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcHeader = map {$_=>1} (
1072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "aliases.h",
1073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argp.h",
1074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argz.h",
1075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assert.h",
1076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "cpio.h",
1077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ctype.h",
1078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dirent.h",
1079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "envz.h",
1080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "errno.h",
1081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "error.h",
1082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "execinfo.h",
1083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fcntl.h",
1084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fstab.h",
1085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ftw.h",
1086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "glob.h",
1087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "grp.h",
1088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "iconv.h",
1089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ifaddrs.h",
1090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inttypes.h",
1091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "langinfo.h",
1092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "limits.h",
1093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "link.h",
1094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "locale.h",
1095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "malloc.h",
1096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "math.h",
1097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mntent.h",
1098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "monetary.h",
1099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nl_types.h",
1100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "obstack.h",
1101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "printf.h",
1102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pwd.h",
1103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "regex.h",
1104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched.h",
1105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "search.h",
1106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "setjmp.h",
1107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "shadow.h",
1108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signal.h",
1109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "spawn.h",
1110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdarg.h",
1111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdint.h",
1112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdio.h",
1113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdlib.h",
1114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "string.h",
11159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "strings.h",
1116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tar.h",
1117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "termios.h",
1118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "time.h",
1119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ulimit.h",
1120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unistd.h",
1121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "utime.h",
1122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar.h",
1123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wctype.h",
1124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wordexp.h" );
1125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcDir = map {$_=>1} (
1127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "arpa",
1128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bits",
1129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gnu",
1130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "netinet",
1131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "net",
1132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nfs",
1133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc",
1134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sys",
1135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "linux" );
1136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %WinHeaders = map {$_=>1} (
11389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "dos.h",
11399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "process.h",
11409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock.h",
11419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config-win.h",
11429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "mem.h",
11439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "windows.h",
11449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock2.h",
11459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "crtdbg.h",
11469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "ws2tcpip.h"
11479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
11499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ObsoleteHeaders = map {$_=>1} (
11509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "iostream.h",
11519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "fstream.h"
11529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
115474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %AlienHeaders = map {$_=>1} (
115574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Solaris
115674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "thread.h",
115774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h",
115874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # HPUX
115974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/stream.h",
116074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Symbian
116174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "AknDoc.h",
116274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Atari ST
116374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ext.h",
116474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "tos.h",
116574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # MS-DOS
116674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "alloc.h",
116774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Sparc
116874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h"
116974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
117074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
11719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ConfHeaders = map {$_=>1} (
11729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "atomic",
11739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "conf.h",
11749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config.h",
11759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "configure.h",
11769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "build.h",
11779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "setup.h"
11789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LocalIncludes = map {$_=>1} (
1181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local/include",
1182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local" );
1183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_AddPath=(
1185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# These paths are needed if the tool cannot detect them automatically
1186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "macos"=>{
1187570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1188570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1189570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/include"
1190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1191570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/lib"
1194570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1195570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1196570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/bin"
1197570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
1199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "beos"=>{
1200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Haiku has GCC 2.95.3 by default
1201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to find GCC>=3.0 in /boot/develop/abi
1202570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1203570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common",
1204570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop"
1205570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/lib",
1208570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/lib",
1209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/apps"
1210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1211570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1212570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/bin",
1213570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/bin",
1214570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop/abi"
1215570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Slash_Type=(
1220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"/",
1221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"\\"
1222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLASH = $Slash_Type{$OSgroup}?$Slash_Type{$OSgroup}:$Slash_Type{"default"};
1225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Global Variables
1227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %COMMON_LANGUAGE=(
1228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  1 => "C",
1229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  2 => "C" );
1230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAX_COMMAND_LINE_ARGUMENTS = 4096;
12329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $MAX_CPPFILT_FILE_SIZE = 50000;
12339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $CPPFILT_SUPPORT_FILE;
12349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy (%WORD_SIZE, %CPU_ARCH, %GCC_VERSION);
1236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $STDCXX_TESTING = 0;
1238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GLIBC_TESTING = 0;
12398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy $CPP_HEADERS = 0;
1240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckHeadersOnly = $CheckHeadersOnly_Opt;
1242570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy $CheckUndefined = 0;
1243570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
124415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenkomy $TargetComponent = undef;
1245dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoif($TargetComponent_Opt) {
1246dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $TargetComponent = lc($TargetComponent_Opt);
1247dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
1248dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoelse
1249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # default: library
1250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # other components: header, system, ...
1251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TargetComponent = "library";
1252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy $TOP_REF = "<a class='top_ref' href='#Top'>to the top</a>";
12551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SystemRoot;
1257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAIN_CPP_DIR;
12591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %RESULT;
1260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LOG_PATH;
1261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DEBUG_PATH;
1262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Cache;
1263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LibInfo;
1264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMPILE_ERRORS = 0;
1265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompilerOptions;
1266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedDyLib;
1267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TargetLibraryShortName = parse_libname($TargetLibraryName, "shortest", $OSgroup);
1268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Constants (#defines)
1270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Constants;
1271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipConstants;
127282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkomy %EnumConstants;
1273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko# Extra Info
127574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %SymbolHeader;
127674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %KnownLibs;
127774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1278177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Templates
1279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TemplateInstance;
1280177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %BasicTemplate;
1281177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateArg;
1282850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkomy %TemplateDecl;
1283177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateMap;
1284177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1285177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Types
1286177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TypeInfo;
1287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipTypes = (
1288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedTypes;
1291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TName_Tid;
1292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %EnumMembName_Id;
1293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %NestedNameSpaces = (
1294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualTable;
12971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VirtualTable_Model;
1298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable;
1299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable_Content;
1300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VTableClass;
1301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AllocableClass;
1302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassMethods;
13031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %ClassNames;
1304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Class_SubClasses;
1305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OverriddenMethods;
13064b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %TypedefToAnon;
130762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy $MAX_ID = 0;
1308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1309177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %CheckedTypeInfo;
1310177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Typedefs
1312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_BaseName;
1313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Tr;
1314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Eq;
1315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdCxxTypedef;
1316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MissedTypedef;
131762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase;
131862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase_R;
13199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TypeTypedef;
1320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols
1322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolInfo;
1323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %tr_name;
1324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name_gcc;
1325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name;
1326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipSymbols = (
1327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipNameSpaces = (
1330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1332a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenkomy %AddNameSpaces = (
1333a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "1"=>{},
1334a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "2"=>{} );
1335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList;
133652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy %TypesList;
1337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList_App;
1338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedSymbols;
133962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Symbol_Library = (
134062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
134162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
134262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Library_Symbol = (
134362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
134462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
134562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepSymbol_Library = (
134662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
134762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
134862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepLibrary_Symbol = (
1349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MangledNames;
13529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %Func_ShortName;
1353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddIntParams;
135462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %GlobalDataObject;
135507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %WeakSymbols;
1356fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Library_Needed= (
1357fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "1"=>{},
1358fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "2"=>{} );
1359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1360570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko# Extra Info
1361570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %UndefinedSymbols;
136274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %PreprocessedHeaders;
1363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Headers
1365570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Preamble = (
1366570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1367570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Registered_Headers;
1369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Registered_Sources;
1370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HeaderName_Paths;
1371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Dependency;
1372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Neighbors;
1373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Paths = (
1374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %INC_PATH_AUTODETECT = (
1377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>1,
1378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>1 );
1379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Add_Include_Paths = (
1380570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1381570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Skip_Include_Paths;
1383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RegisteredDirs;
1384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ErrorRedirect;
1385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Includes;
13868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %Header_Includes_R;
1387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ShouldNotBeUsed;
1388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RecursiveIncludes;
1389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Include_Prefix;
1390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeaders;
1391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeadersList=(
1392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipLibs;
1395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Order;
1396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TUnit_NameSpaces;
1397f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %TUnit_Classes;
13989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Funcs;
13999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Vars;
1400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %CppMode = (
1402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AutoPreambleMode = (
1405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MinGWMode = (
1408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
141001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %Cpp0xMode = (
141101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "1"=>0,
141201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "2"=>0 );
1413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Shared Objects
14159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObjects;
141607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %RegisteredObjects_Short;
14179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredSONAMEs;
14189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObject_Dirs;
1419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1420d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkomy %CheckedArch;
1421d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Objects
1423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemObjects;
1424570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultLibPaths;
14259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %DyLib_DefaultPath;
1426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Headers
1428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemHeaders;
1429570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultCppPaths;
1430570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultGccPaths;
1431570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultIncPaths;
1432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultCppHeader;
1433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultGccHeader;
1434570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @UsersIncPath;
1435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Merging
1437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompleteSignature;
1438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Version;
1439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt;
1440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt;
1441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt_Virt;
1442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt_Virt;
1443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualReplacement;
1444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ChangedTypedef;
1445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatRules;
1446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IncompleteRules;
1447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %UnknownRules;
14481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VTableChanged_M;
144962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %ExtendedSymbols;
1450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ReturnedClass;
1451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ParamClass;
14521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative;
14531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative_B;
14541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceReplacement;
1455f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $CurrentSymbol; # for debugging
1456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1457f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko# Calling Conventions
1458f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %UseConv_Real = (
1459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  1=>{ "R"=>0, "P"=>0 },
1460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  2=>{ "R"=>0, "P"=>0 }
1461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko);
1462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko# ABI Dump
1464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %UsedDump;
1465f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
14666fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Filters
1467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetLibs;
1468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetHeaders;
1469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14706fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Format of objects
1471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OStarget = $OSgroup;
1472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetTools;
1473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Compliance Report
1475dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy %Type_MaxSeverity;
1476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Recursion locks
1478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurLib;
1479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurTypes;
14808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy @RecurTypes_Diff;
1481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurInclude;
1482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurConstant;
1483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System
1485570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %SystemPaths = (
1486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "include"=>[],
1487570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "lib"=>[],
1488570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "bin"=>[]
1489570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
1490570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultBinPaths;
1491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GCC_PATH;
1492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols versioning
1494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymVer = (
1495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Problem descriptions
1499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatProblems;
15008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Constants;
1501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TotalAffected;
1502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Reports
1504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentID = 1;
1505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart = "<span class=\"section\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
15069e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenkomy $ContentSpanStart_Affected = "<span class=\"sect_aff\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
15079e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenkomy $ContentSpanStart_Info = "<span class=\"sect_info\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanEnd = "</span>\n";
1509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivStart = "<div id=\"CONTENT_ID\" style=\"display:none;\">\n";
1510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivEnd = "</div>\n";
1511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Content_Counter = 0;
1512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Modes
15141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $JoinReport = 1;
15151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $DoubleReport = 0;
1516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15172489ef88760861175102e4508089608391beead3Andrey Ponomarenkomy %Severity_Val=(
15182489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "High"=>3,
15192489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Medium"=>2,
15202489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Low"=>1,
15212489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Safe"=>-1
15222489ef88760861175102e4508089608391beead3Andrey Ponomarenko);
15232489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Modules()
1525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TOOL_DIR = get_dirname($0);
1527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TOOL_DIR)
1528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # patch for MS Windows
1529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TOOL_DIR = ".";
1530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SEARCH_DIRS = (
1532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # tool's directory
1533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR),
1534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # relative path to modules
1535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR)."/../share/abi-compliance-checker",
153674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        # install path
153774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        'MODULES_INSTALL_PATH'
1538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
1539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $DIR (@SEARCH_DIRS)
1540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not is_abs($DIR))
1542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative path
1543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $DIR = abs_path($TOOL_DIR)."/".$DIR;
1544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $DIR."/modules") {
1546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $DIR."/modules";
1547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitStatus("Module_Error", "can't find modules");
1550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
155201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %LoadedModules = ();
155301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub loadModule($)
1555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
155701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $LoadedModules{$Name}) {
155801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return;
155901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Name.pm";
1561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $Path) {
1562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    require $Path;
156501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $LoadedModules{$Name} = 1;
1566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub readModule($$)
1569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
1570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Module, $Name) = @_;
1571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
1572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not -f $Path) {
1573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
1575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return readFile($Path);
1576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
1577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
15780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showPos($)
1579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1580dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Number = $_[0];
1581dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Number) {
1582dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = 1;
1583dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1584dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    else {
1585dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = int($Number)+1;
1586dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Number>3) {
1588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number."th";
1589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==1) {
1591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "1st";
1592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==2) {
1594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "2nd";
1595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==3) {
1597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "3rd";
1598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number;
1601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Tools($)
1605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Paths = keys(%TargetTools))
1609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (@Paths)
1611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
161274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-f join_P($Path, $Name)) {
161374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($Path, $Name);
1614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossPrefix)
1616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # user-defined prefix (arm-none-symbianelf, ...)
161774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $Candidate = join_P($Path, $CrossPrefix."-".$Name);
1618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
1620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub synch_Cmd($)
1630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GCC_PATH)
1633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC was not found yet
1634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Candidate = $GCC_PATH;
163762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Candidate=~s/\bgcc(|\.\w+)\Z/$Name$1/) {
1638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Candidate;
1639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
1641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath($)
1644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_CmdPath"}{$Name}) {
1648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_CmdPath"}{$Name};
1649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %BinUtils = map {$_=>1} (
1651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "c++filt",
1652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "objdump",
1653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "readelf"
1654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
165562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($BinUtils{$Name} and $GCC_PATH)
165662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($GCC_PATH)) {
1658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetTools{$Dir}=1;
1659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = search_Tools($Name);
1662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows") {
1663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Tools($Name.".exe");
1664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossPrefix)
1668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user-defined prefix
1669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = search_Cmd($CrossPrefix."-".$Name);
1670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Candidate = synch_Cmd($Name))
1675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # synch with GCC
1676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Candidate=~/[\/\\]/)
16771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command path
1678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path = $Candidate;
1680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Candidate = search_Cmd($Candidate))
16831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command name
1684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Candidate;
1685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path) {
1689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Cmd($Name);
1690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows")
16921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for *.exe file
1693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=search_Cmd($Name.".exe");
1694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\s/) {
1696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = "\"".$Path."\"";
1697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_CmdPath"}{$Name}=$Path);
1699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Cmd($)
1702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"search_Cmd"}{$Name}) {
1706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"search_Cmd"}{$Name};
1707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DefaultPath = get_CmdPath_Default($Name)) {
1709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Cache{"search_Cmd"}{$Name} = $DefaultPath);
1710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1711570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"bin"}})
1712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
171374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $CmdPath = join_P($Path,$Name);
1714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $CmdPath)
1715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name=~/gcc/) {
171762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(not check_gcc($CmdPath, "3"));
1718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"search_Cmd"}{$Name} = $CmdPath);
1720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"search_Cmd"}{$Name} = "");
1723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath_Default($)
1726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search in PATH
172762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $_[0]);
172862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_CmdPath_Default"}{$_[0]}) {
172962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_CmdPath_Default"}{$_[0]};
1730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
173162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_CmdPath_Default"}{$_[0]} = get_CmdPath_Default_I($_[0]));
173262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
173362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
173462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_CmdPath_Default_I($)
173562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # search in PATH
173662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Name = $_[0];
1737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/find/)
1738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # special case: search for "find" utility
1739a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`find \"$TMP_DIR\" -maxdepth 0 2>\"$TMP_DIR/null\"`) {
174062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "find";
1741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/gcc/) {
174462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return check_gcc($Name, "3");
1745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1746570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(checkCmd($Name)) {
174762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Name;
1748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
174962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($OSgroup eq "windows")
175062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1751a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`$Name /? 2>\"$TMP_DIR/null\"`) {
175262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Name;
175362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1755570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultBinPaths)
1756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Name) {
175874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path, $Name);
1759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
176162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
1762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub classifyPath($)
1765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
1767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/[\*\[]/)
1768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # wildcard
1769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\*/.*/g;
1770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\\\\/g;
1771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Pattern");
1772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Path=~/[\/\\]/)
1774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory or relative path
1775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return (path_format($Path, $OSgroup), "Path");
1776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Name");
1779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readDescriptor($$)
1783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Content) = @_;
1785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion);
1786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DName = $DumpAPI?"descriptor":"descriptor \"d$LibVersion\"";
1787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Content) {
1788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "$DName is empty");
1789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content!~/\</) {
17915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        exitStatus("Error", "incorrect descriptor (see -d1 option)");
1792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\/\*(.|\n)+?\*\///g;
1794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/<\!--(.|\n)+?-->//g;
1795570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = parseTag(\$Content, "version");
1797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetVersion{$LibVersion}) {
1798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $TargetVersion{$LibVersion};
1799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{$LibVersion}{"Version"}) {
1801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "version in the $DName is not specified (<version> section)");
1802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/{RELPATH}/)
1804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RelDir = $RelativeDirectory{$LibVersion}) {
1806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Content =~ s/{RELPATH}/$RelDir/g;
1807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
1809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NeedRelpath = $DumpAPI?"-relpath":"-relpath$LibVersion";
1811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "you have not specified $NeedRelpath option, but the $DName contains {RELPATH} macro");
1812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1815ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $DHeaders = parseTag(\$Content, "headers");
1816ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $DHeaders) {
1817ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "header files in the $DName are not specified (<headers> section)");
1818ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
1819ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    elsif(lc($DHeaders) ne "none")
1820ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # append the descriptor headers list
1821ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Headers"})
1822ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # multiple descriptors
1823ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} .= "\n".$DHeaders;
1824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1825ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
1826ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} = $DHeaders;
1827ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
1828ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, $DHeaders))
1829ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
1830ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not -e $Path) {
1831ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$Path\'");
1832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1835ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckHeadersOnly_Opt)
1837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DObjects = parseTag(\$Content, "libs");
1839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DObjects) {
1840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries in the $DName are not specified (<libs> section)");
1841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DObjects) ne "none")
1843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor libraries list
1844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Libs"})
1845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= "\n".$DObjects;
1847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= $DObjects;
1850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DObjects))
1852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_headers")))
1860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1866570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"include"}, $Path);
1867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_libs")))
1869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1875570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, $Path);
1876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "tools")))
1878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1884570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, $Path);
1885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetTools{$Path}=1;
1886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Prefix = parseTag(\$Content, "cross_prefix")) {
1888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CrossPrefix = $Prefix;
1889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1890570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"IncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"IncludePaths"}); # perl 5.8 doesn't support //=
1891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "include_paths")))
1892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1898570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"IncludePaths"}}, $Path);
1899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1900570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"AddIncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"AddIncludePaths"});
1901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "add_include_paths")))
1902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1908570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"AddIncludePaths"}}, $Path);
1909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_include_paths")))
19118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip some auto-generated include paths
19128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not is_abs($Path))
19138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
19148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $P = abs_path($Path)) {
19158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Path = $P;
19168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
19178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
1918570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $Skip_Include_Paths{$LibVersion}{path_format($Path)} = 1;
1919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_including")))
19218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip direct including of some headers
1922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 2;
1924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"GccOptions"} = parseTag(\$Content, "gcc_options");
192674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    foreach my $Option (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"GccOptions"}))
192774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
19288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Option!~/\A\-(Wl|l|L)/)
19298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # skip linker options
193074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $CompilerOptions{$LibVersion} .= " ".$Option;
193174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
1934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipHeaders"}))
1935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = 1;
1937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 1;
1939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipLibs"} = parseTag(\$Content, "skip_libs");
1941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipLibs"}))
1942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipLibs{$LibVersion}{$Type}{$CPath} = 1;
1945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DDefines = parseTag(\$Content, "defines"))
1947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Defines"})
1949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # multiple descriptors
1950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} .= "\n".$DDefines;
1951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} = $DDefines;
1954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
1957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Order=~/\A(.+):(.+)\Z/) {
1959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Order{$LibVersion}{$1} = $2;
1960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")),
1963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_types")))
19641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # opaque_types renamed to skip_types (1.23.4)
1965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipTypes{$LibVersion}{$Type_Name} = 1;
1966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
1968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
19691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # skip_interfaces renamed to skip_symbols (1.22.1)
1970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipSymbols{$LibVersion}{$Symbol} = 1;
1971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "skip_namespaces"))) {
1973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipNameSpaces{$LibVersion}{$NameSpace} = 1;
1974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1975a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "add_namespaces"))) {
1976a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $AddNameSpaces{$LibVersion}{$NameSpace} = 1;
1977a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
1978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (split(/\s*\n\s*/, parseTag(\$Content, "skip_constants"))) {
1979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipConstants{$LibVersion}{$Constant} = 1;
1980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DIncPreamble = parseTag(\$Content, "include_preamble"))
1982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"IncludePreamble"})
19841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # multiple descriptors
1985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} .= "\n".$DIncPreamble;
1986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} = $DIncPreamble;
1989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
199301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub parseTag(@)
1994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
199501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $CodeRef = shift(@_);
199601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Tag = shift(@_);
199701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Tag or not $CodeRef) {
199801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return undef;
199901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
200001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Sp = 0;
200101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(@_) {
200201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Sp = shift(@_);
200301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
200401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Start = index(${$CodeRef}, "<$Tag>");
200501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Start!=-1)
2006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
200701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $End = index(${$CodeRef}, "</$Tag>");
200801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($End!=-1)
200901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
201001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $TS = length($Tag)+3;
201101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Content = substr(${$CodeRef}, $Start, $End-$Start+$TS, "");
201201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, 0, $TS-1, ""); # cut start tag
201301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, -$TS, $TS, ""); # cut end tag
201401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not $Sp)
201501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
201601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\A\s+//g;
201701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\s+\Z//g;
201801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
201901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(substr($Content, 0, 1) ne "<") {
202001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content = xmlSpecChars_R($Content);
202101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
202201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Content;
202301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
202501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return undef;
202601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
202701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getInfo($)
2029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2030850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2031850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $DumpPath or not -f $DumpPath);
2032850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2033850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    readTUDump($DumpPath);
2034850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing info
2036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTemplateParams_All();
20374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
203874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
20394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        setAnonTypedef_All();
20404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
20414b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getTypeInfo_All();
2043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    simplifyNames();
204482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    simplifyConstants();
2045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getVarInfo_All();
204601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    getSymbolInfo_All();
2047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2048850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %LibInfo = ();
2050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %TemplateInstance = ();
2051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    %BasicTemplate = ();
2052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %MangledNames = ();
2053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %TemplateDecl = ();
2054850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %StdCxxTypedef = ();
2055850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %MissedTypedef = ();
2056850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Tr = ();
2057850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Eq = ();
20584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    %TypedefToAnon = ();
2059850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
206062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clean cache
206162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeAttr"});
206262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeDeclId"});
206362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
206474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
2065570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        remove_Unused($Version, "Extra");
206774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
206874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
206974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # remove unused types
2070570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($BinaryOnly and not $ExtendedCheck)
2071570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # --binary
2072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "All");
2073570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
2074570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        else {
2075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "Extended");
2076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2078177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckInfo)
2080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2081177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$Version}})) {
2082177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($TypeInfo{$Version}{$Tid}, $Version);
2083177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2085177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (keys(%{$SymbolInfo{$Version}})) {
2086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($SymbolInfo{$Version}{$Sid}, $Version);
2087570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
208862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
208962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug) {
2091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # debugMangling($Version);
2092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2095850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub readTUDump($)
2096850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
2097850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2098850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2099850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    open(TU_DUMP, $DumpPath);
2100850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    local $/ = undef;
2101850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Content = <TU_DUMP>;
2102850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    close(TU_DUMP);
2103850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2104850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    unlink($DumpPath);
2105850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2106850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Content=~s/\n[ ]+/ /g;
2107d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Lines = split(/\n/, $Content);
2108850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2109850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2110850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef $Content;
2111850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2112177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $MAX_ID = $#Lines+1; # number of lines == number of nodes
2113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (0 .. $#Lines)
2115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
211662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Lines[$_]=~/\A\@(\d+)[ ]+([a-z_]+)[ ]+(.+)\Z/i)
2117850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # get a number and attributes of a node
2118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next if(not $NodeType{$2});
2119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info_type"}{$1}=$2;
21203ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko            $LibInfo{$Version}{"info"}{$1}=$3." ";
2121850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
2124850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($Lines[$_]);
2125850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2126850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2127850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2128850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef @Lines;
2129850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
2130850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
213182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkosub simplifyConstants()
213282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko{
213382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
213482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
2135fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$Version}{$Constant}{"Header"})
2136fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
2137fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Value = $Constants{$Version}{$Constant}{"Value"};
2138fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $EnumConstants{$Version}{$Value}) {
2139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Constants{$Version}{$Constant}{"Value"} = $EnumConstants{$Version}{$Value}{"Value"};
2140fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
214182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
214282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
214382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko}
214482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
2145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simplifyNames()
2146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Base (keys(%{$Typedef_Tr{$Version}}))
2148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2149f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Typedef_Eq{$Version}{$Base}) {
2150f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next;
2151f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2152f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my @Translations = sort keys(%{$Typedef_Tr{$Version}{$Base}});
2153f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($#Translations==0)
2154f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
2155f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(length($Translations[0])<=length($Base)) {
2156f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $Typedef_Eq{$Version}{$Base} = $Translations[0];
2157f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2158f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2159f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else
2160f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # select most appropriate
2161f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            foreach my $Tr (@Translations)
2162f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
2163f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Base=~/\A\Q$Tr\E/)
2164f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
2165f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $Typedef_Eq{$Version}{$Base} = $Tr;
2166f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    last;
2167f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
2168f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2171b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$Version}}))
2172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2173b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $TypeName = $TypeInfo{$Version}{$TypeId}{"Name"};
217462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TypeName) {
217562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
217662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
217762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        next if(index($TypeName,"<")==-1);# template instances only
217862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeName=~/>(::\w+)+\Z/)
217962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip unused types
218062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
2181f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
218262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Base (sort {length($b)<=>length($a)}
218362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        sort {$b cmp $a} keys(%{$Typedef_Eq{$Version}}))
218462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
218562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(not $Base);
218662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(index($TypeName,$Base)==-1);
218762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(length($TypeName) - length($Base) <= 3);
2188f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(my $Typedef = $Typedef_Eq{$Version}{$Base})
2189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2190f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\W|\Z)/$1$Typedef$2/g;
2191f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\w|\Z)/$1$Typedef $2/g;
2192f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(defined $TypeInfo{$Version}{$TypeId}{"TParam"})
2193850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
2194f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    foreach my $TPos (keys(%{$TypeInfo{$Version}{$TypeId}{"TParam"}}))
2195f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
2196f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(my $TPName = $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"})
2197f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
2198f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\W|\Z)/$Typedef$1/g;
2199f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\w|\Z)/$Typedef $1/g;
22009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"} = formatName($TPName, "T");
2201f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
2202f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
2203850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
2204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeName = formatName($TypeName, "T");
2207b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TypeInfo{$Version}{$TypeId}{"Name"} = $TypeName;
2208b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypeName} = $TypeId;
2209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22124b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub setAnonTypedef_All()
22134b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko{
22144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $InfoId (keys(%{$LibInfo{$Version}{"info"}}))
22154b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
22164b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$InfoId} eq "type_decl")
22174b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        {
22184b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(isAnon(getNameByInfo($InfoId))) {
22194b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $TypedefToAnon{getTypeId($InfoId)} = 1;
22204b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
22214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
22224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
22234b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko}
22244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams_All()
2226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (keys(%{$LibInfo{$Version}{"info"}}))
2228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "template_decl") {
2230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setTemplateParams($_);
2231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams($)
2236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2237177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tid = getTypeId($_[0]);
2238989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
2239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2240989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/(inst|spcs)[ ]*:[ ]*@(\d+) /)
2241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
224262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TmplInst_Id = $2;
2243177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            setTemplateInstParams($_[0], $TmplInst_Id);
224462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            while($TmplInst_Id = getNextElem($TmplInst_Id)) {
2245177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                setTemplateInstParams($_[0], $TmplInst_Id);
2246177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2247177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2248177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2249177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $BasicTemplate{$Version}{$Tid} = $_[0];
2250177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2251177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Prms = getTreeAttr_Prms($_[0]))
2252177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2253177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Valu = getTreeAttr_Valu($Prms))
2254177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2255177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Vector = getTreeVec($Valu);
2256177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Vector}))
2257177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2258177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Val = getTreeAttr_Valu($Vector->{$Pos}))
2259177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2260177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Name = getNameByInfo($Val))
2261177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2262177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TemplateArg{$Version}{$_[0]}{$Pos} = $Name;
2263177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if($LibInfo{$Version}{"info_type"}{$Val} eq "parm_decl") {
2264177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = $Val;
2265177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2266177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            else {
2267177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = getTreeAttr_Type($Val);
2268177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2269177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2270177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2271177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2272989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
2273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
227562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $TypeId = getTreeAttr_Type($_[0]))
2276850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
2277850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $IType = $LibInfo{$Version}{"info_type"}{$TypeId})
2278850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
2279850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($IType eq "record_type") {
2280177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TemplateDecl{$Version}{$TypeId} = 1;
2281850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2282850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2283850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2286177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub setTemplateInstParams($$)
2287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2288177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tmpl, $Inst) = @_;
2289177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2290177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$Inst})
2291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my ($Params_InfoId, $ElemId) = ();
2293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
2294989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $Params_InfoId = $1;
2295989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2296989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
2297989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $ElemId = $1;
2298989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2299989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Params_InfoId and $ElemId)
2300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2301989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Params_Info = $LibInfo{$Version}{"info"}{$Params_InfoId};
2302989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($Params_Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
2303989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2304989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my ($PPos, $PTypeId) = ($1, $2);
2305989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if(my $PType = $LibInfo{$Version}{"info_type"}{$PTypeId})
2306989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
2307177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($PType eq "template_type_parm") {
2308177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateDecl{$Version}{$ElemId} = 1;
2309989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
2310989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2311850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($LibInfo{$Version}{"info_type"}{$ElemId} eq "function_decl")
2312850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # functions
231362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Func"}{$ElemId}{$PPos} = $PTypeId;
2314177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2315989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2316850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else
2317850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # types
231862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Type"}{$ElemId}{$PPos} = $PTypeId;
2319177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2320989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeDeclId($)
2327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
232862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0])
2329dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $Cache{"getTypeDeclId"}{$Version}{$_[0]}) {
233162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Cache{"getTypeDeclId"}{$Version}{$_[0]};
233262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
233362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
233462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
233562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+)/) {
233662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = $1);
233762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2338dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
2339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
234062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = 0);
2341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeInfo_All()
2344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
234562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # missed typedefs: QStyle::State is typedef to QFlags<QStyle::StateFlag>
2348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # but QStyleOption.state is of type QFlags<QStyle::StateFlag> in the TU dump
2349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: check GCC versions
2350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Pre();
2351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
235262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
23540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # forward order only
2355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IType = $LibInfo{$Version}{"info_type"}{$_};
2356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($IType=~/_type\Z/ and $IType ne "function_type"
2357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $IType ne "method_type") {
235862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getTypeInfo("$_");
2359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
236162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
236262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # add "..." type
236301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TypeInfo{$Version}{"-1"} = {
236462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Name" => "...",
236562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Type" => "Intrinsic",
236601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        "Tid" => "-1"
236762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    };
236801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TName_Tid{$Version}{"..."} = "-1";
236962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
237062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Post();
2373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2374177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2375177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
2376177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2377177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
2378177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}}))
2379177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2380177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Tid}
2381177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not defined $TypeInfo{$Version}{$Tid}{"Template"})
2382177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2383177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Memb"})
2384177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2385177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Memb"}}))
2386177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2387177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"})
2388177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2389177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if(my %MAttr = getTypeAttr($MembTypeId))
2390177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            {
2391177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"algn"} = $MAttr{"Algn"};
2392177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"} = instType($TemplateMap{$Version}{$Tid}, $MembTypeId, $Version);
2393177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2394177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2395177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Base"})
2398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2399177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Bid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Base"}}))
2400177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $NBid = instType($TemplateMap{$Version}{$Tid}, $Bid, $Version);
2402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
24031b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                        if($NBid ne $Bid
24041b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                        and $NBid ne $Tid)
2405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            %{$TypeInfo{$Version}{$Tid}{"Base"}{$NBid}} = %{$TypeInfo{$Version}{$Tid}{"Base"}{$Bid}};
2407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            delete($TypeInfo{$Version}{$Tid}{"Base"}{$Bid});
2408177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2409177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2410177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2411177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2412177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2413177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2414177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2415177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub createType($$)
2417177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
2418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Attr, $LibVersion) = @_;
2419177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $NewId = ++$MAX_ID;
2420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2421082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko    $Attr->{"Tid"} = $NewId;
2422177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $TypeInfo{$Version}{$NewId} = $Attr;
2423e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $TName_Tid{$Version}{formatName($Attr->{"Name"}, "T")} = $NewId;
2424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "$NewId";
2426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2428177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub instType($$$)
2429177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{ # create template instances
2430177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Map, $Tid, $LibVersion) = @_;
2431be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko
2432be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    if(not $TypeInfo{$LibVersion}{$Tid}) {
2433be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko        return undef;
2434be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    }
2435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Attr = dclone($TypeInfo{$LibVersion}{$Tid});
2436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Key (sort keys(%{$Map}))
2438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Val = $Map->{$Key})
2440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/\b$Key\b/$Val/g;
2442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/\b$Key\b/$Val/g;
2445177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2446177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}})) {
2447177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"TParam"}{$_}{"name"}=~s/\b$Key\b/$Val/g;
2448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2449177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2450177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
2451177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # remove absent
2452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko          # _Traits, etc.
2453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/,\s*\b$Key(,|>)/$1/g;
2454e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/,\s*\b$Key(,|>)/$1/g;
2456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}}))
2458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Attr->{"TParam"}{$_}{"name"} eq $Key) {
2460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($Attr->{"TParam"}{$_});
2461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2462e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                else {
2463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Attr->{"TParam"}{$_}{"name"}=~s/,\s*\b$Key(,|>)/$1/g;
2464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = 0;
2470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Attr->{"TParam"})
2472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (sort {int($a)<=>int($b)} keys(%{$Attr->{"TParam"}}))
2474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $PName = $Attr->{"TParam"}{$_}{"name"};
2476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $PTid = $TName_Tid{$LibVersion}{$PName})
2478177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Base = get_BaseType($PTid, $LibVersion);
2480177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Base{"Type"} eq "TemplateParam"
2482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or defined $Base{"Template"})
2483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Tmpl = 1;
2485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last
2486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2490177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Id = getTypeIdByName($Attr->{"Name"}, $LibVersion)) {
2492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return "$Id";
2493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else
2495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $Tmpl) {
2497177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($Attr->{"Template"});
2498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2500e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my $New = createType($Attr, $LibVersion);
2501e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
2502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %EMap = ();
2503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(defined $TemplateMap{$LibVersion}{$Tid}) {
2504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %EMap = %{$TemplateMap{$LibVersion}{$Tid}};
2505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Map})) {
2507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $EMap{$_} = $Map->{$_};
2508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2510e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"BaseType"}) {
2511e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"BaseType"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"BaseType"}, $LibVersion);
2512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2513e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Base"})
2514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2515e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$New}{"Base"}}))
2516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NBid = instType(\%EMap, $Bid, $LibVersion);
2518177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
25191b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                if($NBid ne $Bid
25201b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                and $NBid ne $New)
2521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2522e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$New}{"Base"}{$NBid}} = %{$TypeInfo{$LibVersion}{$New}{"Base"}{$Bid}};
2523e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$New}{"Base"}{$Bid});
2524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2528e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Memb"})
2529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2530be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Memb"}}))
2531be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            {
2532be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}) {
2533be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}, $LibVersion);
2534be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                }
2535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2538e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Param"})
2539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2540e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Param"}})) {
2541e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"}, $LibVersion);
2542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2545e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Return"}) {
2546e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"Return"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Return"}, $LibVersion);
2547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2549e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        return $New;
2550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Pre()
2554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
255562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %MissedTypes = ();
2556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MissedTDid (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
2557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detecting missed typedefs
2558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$MissedTDid} eq "type_decl")
2559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
256062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeId = getTreeAttr_Type($MissedTDid);
2561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypeId);
256262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeType = getTypeType($TypeId);
2563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeType eq "Unknown")
2564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # template_type_parm
2565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypeDeclId = getTypeDeclId($TypeId);
2568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypeDeclId eq $MissedTDid);#or not $TypeDeclId
2569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypedefName = getNameByInfo($MissedTDid);
2570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypedefName);
2571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypedefName eq "__float80");
2572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(isAnon($TypedefName));
2573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TypeDeclId
2574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or getNameByInfo($TypeDeclId) ne $TypedefName) {
257562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MissedTypes{$Version}{$TypeId}{$MissedTDid} = 1;
2576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2579b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my %AddTypes = ();
258062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$MissedTypes{$Version}}))
2581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add missed typedefs
258262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Missed = keys(%{$MissedTypes{$Version}{$Tid}});
2583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Missed or $#Missed>=1) {
2584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MissedTDid = $Missed[0];
2587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypedefName, $TypedefNS) = getTrivialName($MissedTDid, $Tid);
2588b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $TypedefName) {
2589b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            next;
2590b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        }
2591177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $NewId = ++$MAX_ID;
2592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MissedInfo = ( # typedef info
2593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Name" => $TypedefName,
2594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "NameSpace" => $TypedefNS,
2595fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            "BaseType" => $Tid,
2596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Type" => "Typedef",
2597177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            "Tid" => "$NewId" );
2598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($H, $L) = getLocation($MissedTDid);
2599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Header"} = $H;
2600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Line"} = $L;
2601b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/\*|\&|\s/)
2602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # other types
2603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2605b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/>(::\w+)+\Z/)
2606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # QFlags<Qt::DropAction>::enum_type
2607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
260962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(getTypeType($Tid)=~/\A(Intrinsic|Union|Struct|Enum|Class)\Z/)
2610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # double-check for the name of typedef
261162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my ($TName, $TNS) = getTrivialName(getTypeDeclId($Tid), $Tid); # base type info
2612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TName);
2613b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(length($TypedefName)>=length($TName))
2614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too long typedef
2615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2617b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TName=~/\A\Q$TypedefName\E</) {
2618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2620b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TypedefName=~/\A\Q$TName\E/)
2621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # QDateTimeEdit::Section and QDateTimeEdit::Sections::enum_type
2622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2624b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(get_depth($TypedefName)==0 and get_depth($TName)!=0)
2625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # std::_Vector_base and std::vector::_Base
2626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2629b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2630b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $AddTypes{$MissedInfo{"Tid"}} = \%MissedInfo;
2631b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # register typedef
2633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"Tid"} = $MissedInfo{"Tid"};
263462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"TDid"} = $MissedTDid;
2635b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypedefName} = $MissedInfo{"Tid"};
2636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2637b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2638b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    # add missed & remove other
2639b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    $TypeInfo{$Version} = \%AddTypes;
2640b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    delete($Cache{"getTypeAttr"}{$Version});
2641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Post()
2644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (keys(%{$MissedTypedef{$Version}}))
2646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
264762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Tid = $MissedTypedef{$Version}{$BaseId}{"Tid"})
264862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
264962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$Version}{$Tid}{"Size"} = $TypeInfo{$Version}{$BaseId}{"Size"};
265062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $TName = $TypeInfo{$Version}{$Tid}{"Name"}) {
265162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Typedef_BaseName{$Version}{$TName} = $TypeInfo{$Version}{$BaseId}{"Name"};
265262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
265362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
265762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeInfo($)
2658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2659b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TypeId = $_[0];
2660b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    %{$TypeInfo{$Version}{$TypeId}} = getTypeAttr($TypeId);
2661b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TName = $TypeInfo{$Version}{$TypeId}{"Name"};
2662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TName) {
2663b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        delete($TypeInfo{$Version}{$TypeId});
2664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArraySize($$)
2668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $BaseName) = @_;
267062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Size = getSize($TypeId))
2671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
267262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Elems = $Size/$BYTE_SIZE;
267362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($BaseName=~s/\s*\[(\d+)\]//) {
267462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Elems/=$1;
2675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
267662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BasicId = $TName_Tid{$Version}{$BaseName})
267762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
267862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $BasicSize = $TypeInfo{$Version}{$BasicId}{"Size"}) {
267962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Elems/=$BasicSize;
268062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
268262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Elems;
2683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
268462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
2685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTParams($$)
2688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
268962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $Kind) = @_;
269062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @TmplParams = ();
269162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @Positions = sort {int($a)<=>int($b)} keys(%{$TemplateInstance{$Version}{$Kind}{$TypeId}});
269262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (@Positions)
2693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
269462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Param_TypeId = $TemplateInstance{$Version}{$Kind}{$TypeId}{$Pos};
269562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $NodeType = $LibInfo{$Version}{"info_type"}{$Param_TypeId};
269662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $NodeType)
269762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # typename_type
2698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
270062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($NodeType eq "tree_vec")
270162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
270262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Pos!=$#Positions)
270362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # select last vector of parameters ( ns<P1>::type<P2> )
270462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next;
270562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
270662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
270762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = get_TemplateParam($Pos, $Param_TypeId);
270862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P (@Params)
270962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
271062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P eq "") {
271162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
271262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
271362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($P ne "\@skip\@") {
271462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @TmplParams = (@TmplParams, $P);
271562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
271862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return @TmplParams;
2719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
272162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeAttr($)
2722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
272362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
27240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my %TypeAttr = ();
272562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TypeInfo{$Version}{$TypeId}
272662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $TypeInfo{$Version}{$TypeId}{"Name"})
272762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # already created
272862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$TypeInfo{$Version}{$TypeId}};
2729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
273062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($Cache{"getTypeAttr"}{$Version}{$TypeId})
273162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incomplete type
273262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ();
273362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
273462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"getTypeAttr"}{$Version}{$TypeId} = 1;
273562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
273662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
2737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
273862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
273962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $MissedBase{$Version}{$TypeId} and isTypedef($TypeId))
274062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
274162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
274262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
274362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/qual[ ]*:/)
274462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2745177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NewId = ++$MAX_ID;
2746177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2747177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase{$Version}{$TypeId} = "$NewId";
2748177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase_R{$Version}{$NewId} = $TypeId;
2749177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info"}{$NewId} = $LibInfo{$Version}{"info"}{$TypeId};
2750177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info_type"}{$NewId} = $LibInfo{$Version}{"info_type"}{$TypeId};
275162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
275262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
275362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = "Typedef";
275462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
275562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
275662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = getTypeType($TypeId);
275762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
275862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2759177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $ScopeId = getTreeAttr_Scpe($TypeDeclId))
2760177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2761177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$ScopeId} eq "function_decl")
2762177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # local code
2763177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2764177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2765177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2766177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Unknown") {
2768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
2769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"}=~/(Func|Method|Field)Ptr/)
2771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
277262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getMemPtrAttr(pointTo($TypeId), $TypeId, $TypeAttr{"Type"});
2773989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(my $TName = $TypeAttr{"Name"})
2774989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
277562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2776989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TName} = $TypeId;
2777989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2778989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2779989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        else {
2780989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return ();
2781989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"} eq "Array")
2784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
278562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
278662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
27870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
27880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2789f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2790f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2791f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2792fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
279362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my %BTAttr = getTypeAttr($BTid))
2794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
279562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $BTAttr{"Name"}) {
279662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
279762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
27980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $NElems = getArraySize($TypeId, $BTAttr{"Name"}))
2799989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
280062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Size = getSize($TypeId)) {
280162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeAttr{"Size"} = $Size/$BYTE_SIZE;
280262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
28030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2804989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[$NElems]".$2;
2805989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2806989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[$NElems]";
2808989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2810989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
2811989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2812989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version}; # pointer
28130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2814989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[]".$2;
2815989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2816989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[]";
2818989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
28209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
28210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BTAttr{"Header"})  {
28220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Header"} = $BTAttr{"Header"};
2823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
282462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2825989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2826989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return ();
2829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2830177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/\A(Intrinsic|Union|Struct|Enum|Class|Vector)\Z/)
2831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
283262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
28330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"})
28340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
283562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2836177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2837177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $IntrinsicNames{$TypeAttr{"Name"}}
2838177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or getTypeDeclId($TypeAttr{"Tid"}))
28390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # NOTE: register only one int: with built-in decl
28400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
28410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
28420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
28430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
28440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return %TypeAttr;
28450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
28460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
28470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2850177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/TemplateParam|TypeName/)
2851177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2852177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
2853177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2856177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
2857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2860177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2861177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2862177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"} eq "SizeOf")
2866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"BaseType"} = getTreeAttr_Type($TypeId);
2868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
2869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Name"} = "sizeof(".$BTAttr{"Name"}.")";
2870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2875177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
2880989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # derived types
288162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
288262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
28830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2885fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
288662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$BTid})
2887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
288862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $MissedTDid = $MissedTypedef{$Version}{$BTid}{"TDid"})
2889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
289062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($MissedTDid ne $TypeDeclId) {
2891fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeAttr{"BaseType"} = $MissedTypedef{$Version}{$BTid}{"Tid"};
289262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2895fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
28960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $BTAttr{"Name"})
289762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # templates
2898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTAttr{"Type"} eq "Typedef")
2901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relinking typedefs
2902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %BaseBase = get_Type($BTAttr{"BaseType"}, $Version);
290362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($BTAttr{"Name"} eq $BaseBase{"Name"}) {
2904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TypeAttr{"BaseType"} = $BaseBase{"Tid"};
2905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTSpec)
2908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer"
29100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BTAttr{"Name"}=~/\([\*]+\)/)
2911989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
29120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"};
2913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Name"}=~s/\(([*]+)\)/($1*)/g;
2914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
29160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"}." ".$BTSpec;
2917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
29200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Name"} = $BTAttr{"Name"};
2921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TypeAttr{"Type"} eq "Typedef")
2923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Name"} = getNameByInfo($TypeDeclId);
292574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
292674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(index($TypeAttr{"Name"}, "tmp_add_type")==0) {
292774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return ();
292874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
292974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2930850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(isAnon($TypeAttr{"Name"}))
2931850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # anon typedef to anon type: ._N
2932850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return ();
2933850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
29348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
29358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$TypeDeclId}=~/ artificial /i)
29368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # artificial typedef of "struct X" to "X"
29378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeAttr{"Artificial"} = 1;
29388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
29398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
2940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $NS = getNameSpace($TypeDeclId))
2941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $TypeName = $TypeAttr{"Name"};
2943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NS=~/\A(struct |union |class |)((.+)::|)\Q$TypeName\E\Z/)
2944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # "some_type" is the typedef to "struct some_type" in C++
2945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($3) {
2946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TypeAttr{"Name"} = $3."::".$TypeName;
2947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
2950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"NameSpace"} = $NS;
2952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
2953989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2954989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($TypeAttr{"NameSpace"}=~/\Astd(::|\Z)/
2955989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    and $TypeAttr{"Name"}!~/>(::\w+)+\Z/)
2956989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
29570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($BTAttr{"NameSpace"}
29580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        and $BTAttr{"NameSpace"}=~/\Astd(::|\Z)/ and $BTAttr{"Name"}=~/</)
2959989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        { # types like "std::fpos<__mbstate_t>" are
2960989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # not covered by typedefs in the TU dump
2961989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # so trying to add such typedefs manually
29620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $StdCxxTypedef{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if(length($TypeAttr{"Name"})<=length($BTAttr{"Name"}))
2964989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                            {
29650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/))
2966989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                { # skip "other" in "std" and "type" in "boost"
29670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                    $Typedef_Eq{$Version}{$BTAttr{"Name"}} = $TypeAttr{"Name"};
2968989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                }
2969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
2970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
2971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TypeAttr{"Name"} ne $BTAttr{"Name"} and not $TypeAttr{"Artificial"}
29750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $TypeAttr{"Name"}!~/>(::\w+)+\Z/ and $BTAttr{"Name"}!~/>(::\w+)+\Z/)
2976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
29770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not defined $Typedef_BaseName{$Version}{$TypeAttr{"Name"}})
29780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # typedef int*const TYPEDEF; // first
29790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # int foo(TYPEDEF p); // const is optimized out
29800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Typedef_BaseName{$Version}{$TypeAttr{"Name"}} = $BTAttr{"Name"};
29810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if($BTAttr{"Name"}=~/</)
29820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
29830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/)) {
29840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Typedef_Tr{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
2986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeDeclId);
2990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TypeAttr{"Size"})
2992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer") {
2994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version};
2995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($BTAttr{"Size"}) {
29970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Size"} = $BTAttr{"Size"};
2998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3000f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
3001f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3002f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
30039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
30040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $TypeAttr{"Header"} and $BTAttr{"Header"})  {
30050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Header"} = $BTAttr{"Header"};
3006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
300762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
30080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"} ne $BTAttr{"Name"})
3009989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # typedef to "class Class"
3010989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko          # should not be registered in TName_Tid
3011989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3012989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3013989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
3014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %TypeAttr;
3016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
301962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeVec($)
302062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
302162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Vector = ();
302262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
302362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
302462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
302562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # string length is N-1 because of the null terminator
302662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Vector{$1} = $2;
302762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
302862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
302962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return \%Vector;
303062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
303162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TemplateParam($$)
3033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $Type_Id) = @_;
303562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type_Id);
303662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $NodeType = $LibInfo{$Version}{"info_type"}{$Type_Id};
303762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $NodeType);
303862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($NodeType eq "integer_cst")
3039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # int (1), unsigned (2u), char ('c' as 99), ...
304062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $CstTid = getTreeAttr_Type($Type_Id);
3041b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my %CstType = getTypeAttr($CstTid); # without recursion
3042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = getNodeIntCst($Type_Id);
3043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $CstSuffix = $ConstantSuffix{$CstType{"Name"}}) {
304462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Num.$CstSuffix);
3045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
304762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("(".$CstType{"Name"}.")".$Num);
3048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
305062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "string_cst") {
305162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getNodeStrCst($Type_Id));
3052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
305362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "tree_vec")
305462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
305562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Vector = getTreeVec($Type_Id);
305662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = ();
305762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P1 (sort {int($a)<=>int($b)} keys(%{$Vector}))
305862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
305962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $P2 (get_TemplateParam($Pos, $Vector->{$P1})) {
306062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@Params, $P2);
306162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
306262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
306362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return @Params;
3064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($NodeType eq "parm_decl")
3066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        (getNameByInfo($Type_Id));
3068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
307162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ParamAttr = getTypeAttr($Type_Id);
3072b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $PName = $ParamAttr{"Name"};
3073b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $PName) {
307462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ();
3075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3076b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($PName=~/\>/)
3077b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        {
3078b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(my $Cover = cover_stdcxx_typedef($PName)) {
3079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PName = $Cover;
3080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Pos>=1 and
30831477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        $PName=~/\A$DEFAULT_STD_PARMS\</)
3084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
3085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Key, typename _Compare = std::less<_Key>
3086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
3087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
3088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
3089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
309062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("\@skip\@");
3091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
309262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($PName);
3093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cover_stdcxx_typedef($)
3097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
3099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)}
3100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # take the shortest typedef
3102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: there may be more than
3103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # one typedefs to the same type
3104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Covers[0];
3105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3106f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Covered = $TypeName;
3107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName=~s/(>)[ ]*(const|volatile|restrict| |\*|\&)\Z/$1/g){};
3108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)} sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3110f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Cover = $Covers[0])
3111f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
3112f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\W|\Z)/$Cover$1/g;
3113f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\w|\Z)/$Cover $1/g;
3114f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
31169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return formatName($Covered, "T");
3117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeIntCst($)
3120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $CstId = $_[0];
312262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CstTypeId = getTreeAttr_Type($CstId);
3123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($EnumMembName_Id{$Version}{$CstId}) {
3124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $EnumMembName_Id{$Version}{$CstId};
3125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif((my $Value = getTreeValue($CstId)) ne "")
3127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3128dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Value eq "0")
3129dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
313062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "false";
3132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "0";
3135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3137dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Value eq "1")
3138dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
313962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "true";
3141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "1";
3144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Value;
3148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3150dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeStrCst($)
3154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3157dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/strg[ ]*: (.+) lngt:[ ]*(\d+)/)
315801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
315901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$_[0]} eq "string_cst")
316001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # string length is N-1 because of the null terminator
316101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2-1);
316201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
316301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            else
316401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # identifier_node
316501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2);
316601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
3167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3169dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
317262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getMemPtrAttr($$$)
3173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # function, method and field pointers
317462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($PtrId, $TypeId, $Type) = @_;
3175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo = $LibInfo{$Version}{"info"}{$PtrId};
3176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr") {
3177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemInfo = $LibInfo{$Version}{"info"}{$TypeId};
3178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo_Type = $LibInfo{$Version}{"info_type"}{$PtrId};
3180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemPtrName = "";
318162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TypeAttr = ("Size"=>$WORD_SIZE{$Version}, "Type"=>$Type, "Tid"=>$TypeId);
3182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "MethodPtr")
3183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # size of "method pointer" may be greater than WORD size
318401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Size = getSize($TypeId))
318501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
318601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $Size/=$BYTE_SIZE;
318701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr{"Size"} = "$Size";
318862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3190f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3191f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3192f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Return
3194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr")
3195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
319662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ReturnAttr = getTypeAttr($PtrId);
3197989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($ReturnAttr{"Name"}) {
3198989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3199989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
3200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Return"} = $PtrId;
3201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/retn[ ]*:[ ]*\@(\d+) /)
3205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnTypeId = $1;
320762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %ReturnAttr = getTypeAttr($ReturnTypeId);
320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $ReturnAttr{"Name"})
320962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
321062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
3211989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
321262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Return"} = $ReturnTypeId;
3214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Class
3217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemInfo=~/(clas|cls)[ ]*:[ ]*@(\d+) /)
3218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Class"} = $2;
322062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class = getTypeAttr($TypeAttr{"Class"});
3221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Class{"Name"}) {
3222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (".$Class{"Name"}."\:\:*)";
3223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (*)";
3226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
3229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (*)";
3230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Parameters
3232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FuncPtr"
3233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type eq "MethodPtr")
3234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ParamTypeName = ();
3236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/prms[ ]*:[ ]*@(\d+) /)
3237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3238989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $PTypeInfoId = $1;
323901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my ($Pos, $PPos) = (0, 0);
3240989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($PTypeInfoId)
3241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3242989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my $PTypeInfo = $LibInfo{$Version}{"info"}{$PTypeInfoId};
3243989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($PTypeInfo=~/valu[ ]*:[ ]*@(\d+) /)
3244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
324562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $PTypeId = $1;
324662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %ParamAttr = getTypeAttr($PTypeId);
3247989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if(not $ParamAttr{"Name"})
3248989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    { # templates (template_type_parm), etc.
3249989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        return ();
3250989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3251989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($ParamAttr{"Name"} eq "void") {
3252989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3253989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
325462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Pos!=0 or $Type ne "MethodPtr")
3255989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
325601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TypeAttr{"Param"}{$PPos++}{"type"} = $PTypeId;
3257989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        push(@ParamTypeName, $ParamAttr{"Name"});
3258989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
325962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($PTypeInfoId = getNextElem($PTypeInfoId)) {
326062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Pos+=1;
3261989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3262989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    else {
3263989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3264989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3265989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
3266989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
3267989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    last;
3268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (".join(", ", @ParamTypeName).")";
3272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
32739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($MemPtrName, "T");
3274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
3275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeTypeName($)
3278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
32790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
32800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
32820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "integer_type")
3283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
32840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Name = getNameByInfo($TypeId))
32850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # bit_size_type
32860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Name;
32870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
32880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($Info=~/unsigned/) {
3289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "unsigned int";
3290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "int";
3293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
32954b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        elsif($Info=~/name[ ]*:[ ]*@(\d+) /) {
32960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return getNameByInfo($1);
32970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
33020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFuncPtr($)
3303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
33040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/unql[ ]*:/ and $Info!~/qual[ ]*:/) {
33090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 0;
33100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $InfoT1 = $LibInfo{$Version}{"info_type"}{$_[0]}
33130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    and my $InfoT2 = $LibInfo{$Version}{"info_type"}{$Ptd})
3314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($InfoT1 eq "pointer_type"
33160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $InfoT2 eq "function_type") {
33170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isMethodPtr($)
33240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "record_type"
33300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$Ptd} eq "method_type"
33310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFieldPtr($)
33390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "offset_type"
33430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub pointTo($)
33510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+)/) {
33550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $1;
3356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "";
33590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getTypeTypeByTypeId($)
33620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
33640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $TType = $LibInfo{$Version}{"info_type"}{$TypeId})
33650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $NType = $NodeType{$TType};
33670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($NType eq "Intrinsic") {
33680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFuncPtr($TypeId)) {
33710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FuncPtr";
33720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isMethodPtr($TypeId)) {
33740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "MethodPtr";
33750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFieldPtr($TypeId)) {
33770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FieldPtr";
33780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($NType ne "Other") {
33800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Unknown";
3384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
338674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %UnQual = (
338774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "r"=>"restrict",
338874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "v"=>"volatile",
338974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "c"=>"const",
339074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "cv"=>"const volatile"
339174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
339274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getQual($)
3394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
3396dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3397dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3398dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($Qual, $To) = ();
3399dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/qual[ ]*:[ ]*(r|c|v|cv) /) {
3400dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Qual = $UnQual{$1};
3401dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3402dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*\@(\d+)/) {
3403dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $To = $1;
3404dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3405dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Qual and $To) {
3406dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return ($Qual, $To);
3407dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ();
3410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualType($)
34130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] eq "const volatile") {
34150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "ConstVolatile";
34160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ucfirst($_[0]);
34180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
342062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeType($)
34210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
342262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
342362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
342462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
34250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # support for old GCC versions
342662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq $TypeDeclId) {
342762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "Typedef";
342862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
34290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
34329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(($Qual or $To) and $TypeDeclId
34339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and (getTypeId($TypeDeclId) ne $TypeId))
34340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
343562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return getQualType($Qual);
34360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
343762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MissedBase_R{$Version}{$TypeId}
343862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and isTypedef($TypeId)) {
34390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Typedef";
34400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual)
34420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
34430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return getQualType($Qual);
34440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info=~/unql[ ]*:[ ]*\@(\d+)/)
34479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # typedef struct { ... } name
34489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeTypedef{$Version}{$TypeId} = $1;
34499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
34509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeType = getTypeTypeByTypeId($TypeId);
34520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($TypeType eq "Struct")
34530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeDeclId
34550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$TypeDeclId} eq "template_decl") {
34560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "Template";
34570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
34580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $TypeType;
34600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
346262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub isTypedef($)
346362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
3464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0])
346562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "vector_type")
3467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
3468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return 0;
3469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3472e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(my $TDid = getTypeDeclId($_[0]))
3473e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            {
3474e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(getTypeId($TDid) eq $_[0]
3475e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                and getNameByInfo($TDid))
3476e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                {
3477e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if($Info=~/unql[ ]*:[ ]*\@(\d+) /) {
3478e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                        return $1;
3479e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3480e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
3481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
348262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
348362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
348462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
348562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
348662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
348762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectBaseType($)
3488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
348962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
349062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
349162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add missed typedefs
349262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq getTypeDeclId($TypeId)) {
349362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($TypeId, "");
349462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $InfoType = $LibInfo{$Version}{"info_type"}{$TypeId};
349862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
349962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB_R = $MissedBase_R{$Version}{$TypeId};
350062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB = $MissedBase{$Version}{$TypeId};
350162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3502dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
35030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(($Qual or $To) and $Info=~/name[ ]*:[ ]*\@(\d+) /
350462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (getTypeId($1) ne $TypeId)
350562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (not $MB_R or getTypeId($1) ne $MB_R))
35060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
350762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getTypeId($1), $Qual);
350862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
350962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($MB)
351062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add base
351162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($MB, "");
3512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
351362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MB_R and my $Bid = isTypedef($TypeId))
3514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # typedefs
351562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($Bid, "");
3516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual or $To)
35180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
351962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($To, $Qual);
3520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "reference_type")
3522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/refd[ ]*:[ ]*@(\d+) /) {
352462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "&");
3525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "array_type")
3528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/elts[ ]*:[ ]*@(\d+) /) {
353062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "");
3531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "pointer_type")
3534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+) /) {
353662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "*");
3537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return (0, "");
3541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo_All()
3544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "function_decl") {
354862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getSymbolInfo($_);
3549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
3553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
3555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$Version}}))
3556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Map = ();
3558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $ClassId = $SymbolInfo{$Version}{$Sid}{"Class"})
3560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TemplateMap{$Version}{$ClassId})
3562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%{$TemplateMap{$Version}{$ClassId}})) {
3564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Map{$_} = $TemplateMap{$Version}{$ClassId}{$_};
3565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Sid})
3570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$TemplateMap{$Version}{$Sid}})) {
3572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Map{$_} = $TemplateMap{$Version}{$Sid}{$_};
3573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $SymbolInfo{$Version}{$Sid}{"Param"})
3577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$SymbolInfo{$Version}{$Sid}{"Param"}}))
3579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $PTid = $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"};
3581177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"} = instType(\%Map, $PTid, $Version);
3582177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3583177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Return = $SymbolInfo{$Version}{$Sid}{"Return"}) {
3585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $SymbolInfo{$Version}{$Sid}{"Return"} = instType(\%Map, $Return, $Version);
3586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo_All()
3592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "var_decl") {
359662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getVarInfo($_);
3597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isBuiltIn($) {
3602dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($_[0] and $_[0]=~/\<built\-in\>|\<internal\>|\A\./);
3603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo($)
3606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
360801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $NSid = getTreeAttr_Scpe($InfoId))
3609dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3610dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $NSInfoType = $LibInfo{$Version}{"info_type"}{$NSid};
3611dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($NSInfoType and $NSInfoType eq "function_decl") {
3612dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return;
3613dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
3616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
3617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"})) {
3618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
362162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = getTreeStr(getTreeAttr_Name($InfoId));
3622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $ShortName) {
3623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($ShortName=~/\Atmp_add_class_\d+\Z/) {
3627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
3629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = $ShortName;
3631f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
3632f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
3633f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
3634f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
3635f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
3636f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3637f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
3638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
36409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
3641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate mangled name
3642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($ShortName, "_Z")==0)
36470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # _ZTS, etc.
3648850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
36490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
36500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(isPrivateData($SymbolInfo{$Version}{$InfoId}{"MnglName"}))
36510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
36520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
36530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
36540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
3655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Data"} = 1;
365662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = getTypeId($InfoId))
36570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
3658177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Rid}
3659177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Rid}{"Name"})
3660177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
36610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
36620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return;
36630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
366462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Rid;
366562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Val = getDataVal($InfoId, $Rid);
36660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Val) {
36670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Value"} = $Val;
36680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    set_Class_And_Namespace($InfoId);
367162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
367262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3673177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
3674177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
3675177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
367662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
367762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
367862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
367962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
368035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
368135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
3682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
368335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3685dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
3686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
3687850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $CheckHeadersOnly)
36905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
36915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Class"})
36925c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        {
36935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
36955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
36965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if(link_symbol($ShortName, $Version, "-Deps"))
36975c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                { # "const" global data is mangled as _ZL... in the TU dump
36985c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                  # but not mangled when compiling a C shared library
36995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
37005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
37015c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
37025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
37035c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
3704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
3705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for some symbols (_ZTI) the short name is the mangled name
37089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($ShortName, "_Z")==0) {
3709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
3714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"MnglName"} = linkSymbol($InfoId);
3715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
3717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
3719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # link MS C++ symbols from library with GCC symbols from headers
3720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
3721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}) {
3725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3727850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3728850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
3729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
3730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
3731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
3732850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return;
3733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
373562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
373662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
373762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
373862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
373962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
374062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
374162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
374262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setFuncAccess($InfoId);
37459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_ZTV")==0) {
3746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
3747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShortName=~/\A(_Z|\?)/) {
3749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"ShortName"});
3750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
375174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
375274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
375374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
375474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
3755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3757850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub isConstType($$)
3758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
3759850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
376062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Base = get_Type($TypeId, $LibVersion);
3761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    while(defined $Base{"Type"} and $Base{"Type"} eq "Typedef") {
3762f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        %Base = get_OneStep_BaseType($Base{"Tid"}, $TypeInfo{$LibVersion});
3763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Base{"Type"} eq "Const");
3765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
3766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTrivialName($$)
3768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeInfoId, $TypeId) = @_;
3770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeAttr = ();
3771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"} = getNameByInfo($TypeInfoId);
3772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = getTreeTypeName($TypeId);
3774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3775dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
377662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"}=~s/<(.+)\Z//g; # GCC 3.4.4 add template params to the name
37781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
37791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
37801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $NameSpaceId = $TypeId;
378101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        while(my $NSId = getTreeAttr_Scpe(getTypeDeclId($NameSpaceId)))
37821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # searching for a first not anon scope
37831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NSId eq $NameSpaceId) {
37841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                last;
37851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
37861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
37871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
37881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace(getTypeDeclId($TypeId));
37891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $TypeAttr{"NameSpace"}
37902956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko                or not isAnon($TypeAttr{"NameSpace"})) {
37911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    last;
37921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
37931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3794177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $NameSpaceId = $NSId;
37951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
37961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
37971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
37981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
379901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $NameSpaceId = getTreeAttr_Scpe($TypeInfoId))
38001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
38011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NameSpaceId ne $TypeId) {
38021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace($TypeInfoId);
38031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38062956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko    if($TypeAttr{"NameSpace"} and not isAnon($TypeAttr{"Name"})) {
3807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
3810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
38111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # anon-struct-header.h-line
3812dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $TypeAttr{"Name"} = "anon-".lc($TypeAttr{"Type"})."-";
3813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} .= $TypeAttr{"Header"}."-".$TypeAttr{"Line"};
3814dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($TypeAttr{"NameSpace"}) {
3815dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3816dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3818b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId}
3819b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    and getTypeDeclId($TypeId) eq $TypeInfoId)
3820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3821b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type")) {
3822b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."< ".join(", ", @TParams)." >", "T");
3823b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3824b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
3825b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."<...>", "T");
3826b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"});
3829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
383162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTrivialTypeAttr($)
3832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
383362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
383462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeInfoId = getTypeDeclId($_[0]);
3835850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3836177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %TypeAttr = ();
3837177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3838850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TemplateDecl{$Version}{$TypeId})
3839850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # template_decl
3840177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Template"} = 1;
384162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
3842850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTypeAccess($TypeId, \%TypeAttr);
3844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
3845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isBuiltIn($TypeAttr{"Header"}))
3846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Header"});
3848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Line"});
3849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38502489ef88760861175102e4508089608391beead3Andrey Ponomarenko
385162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"}) = getTrivialName($TypeInfoId, $TypeId);
3853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
3855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"NameSpace"}) {
3857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"NameSpace"});
3858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
38602489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Intrinsic")
38612489ef88760861175102e4508089608391beead3Andrey Ponomarenko    {
38622489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(defined $TypeAttr{"Header"})
38632489ef88760861175102e4508089608391beead3Andrey Ponomarenko        {
38642489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if($TypeAttr{"Header"}=~/\Adump[1-2]\.[ih]\Z/)
38652489ef88760861175102e4508089608391beead3Andrey Ponomarenko            { # support for SUSE 11.2
38662489ef88760861175102e4508089608391beead3Andrey Ponomarenko              # integer_type has srcp dump{1-2}.i
38672489ef88760861175102e4508089608391beead3Andrey Ponomarenko                delete($TypeAttr{"Header"});
38682489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
38692489ef88760861175102e4508089608391beead3Andrey Ponomarenko        }
38702489ef88760861175102e4508089608391beead3Andrey Ponomarenko    }
38712489ef88760861175102e4508089608391beead3Andrey Ponomarenko
3872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = undef;
3873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
387462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId})
38751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
3876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $Tmpl = $BasicTemplate{$Version}{$TypeId};
3877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
387862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type"))
38791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
3880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (0 .. $#TParams)
3881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Val = $TParams[$Pos];
3883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"TParam"}{$Pos}{"name"} = $Val;
3884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not defined $TypeAttr{"Template"})
3886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my %Base = get_BaseType($TemplateInstance{$Version}{"Type"}{$TypeId}{$Pos}, $Version);
3888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Base{"Type"} eq "TemplateParam"
3890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or defined $Base{"Template"}) {
3891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeAttr{"Template"} = 1;
3892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Tmpl)
3896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
3898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = $Val;
3900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($Val eq $Arg) {
3902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TypeAttr{"Template"} = 1;
3903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
3909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
3911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Pos>$#TParams)
3913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
3915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = "";
3916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3919177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3920177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3921177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ADD_TMPL_INSTANCES)
3922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3923e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if($Tmpl)
3924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3925e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(my $MainInst = getTreeAttr_Type($Tmpl))
3926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3927e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Flds($TypeId))
3928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3929177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Flds = getTreeAttr_Flds($MainInst)) {
3930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " flds: \@$Flds ";
3931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3932e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3933e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Binf($TypeId))
3934e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    {
3935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Binf = getTreeAttr_Binf($MainInst)) {
3936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " binf: \@$Binf ";
3937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
39401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
39411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
39421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
3943177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3944177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $StaticFields = setTypeMemb($TypeId, \%TypeAttr);
3945177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
394601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Size = getSize($TypeId))
394701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
394801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Size = $Size/$BYTE_SIZE;
394901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeAttr{"Size"} = "$Size";
3950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
3952177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ExtraDump)
3954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $TypeAttr{"Memb"}
3956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not $Tmpl)
3957177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # declaration only
3958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"Forward"} = 1;
3959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3960177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
39619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
396274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
396474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    and ($StaticFields or detect_lang($TypeId)))
3965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Type"} = "Class";
3967850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $TypeAttr{"Copied"} = 1; # default, will be changed in getSymbolInfo()
3968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
3970850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    or $TypeAttr{"Type"} eq "Class")
3971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
397262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Skip = setBaseClasses($TypeId, \%TypeAttr);
3973850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Skip) {
3974850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return ();
3975850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3977f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3978f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3979f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setSpec($TypeId, \%TypeAttr);
398174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
398274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeAttr{"Type"}=~/\A(Struct|Union|Enum)\Z/)
398374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
398474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $TypedefToAnon{$TypeId}
3985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        and not defined $TemplateInstance{$Version}{"Type"}{$TypeId})
398674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
398774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not isAnon($TypeAttr{"Name"})) {
398874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeAttr{"Name"} = lc($TypeAttr{"Type"})." ".$TypeAttr{"Name"};
398974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
399074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
399174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
399274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
3994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VTable = $ClassVTable_Content{$Version}{$TypeAttr{"Name"}})
3995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Entries = split(/\n/, $VTable);
3997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $#Entries)
3998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Entry = $Entries[$_];
4000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry=~/\A(\d+)\s+(.+)\Z/) {
4001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"VTable"}{$1} = simplifyVTable($2);
4002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
400582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
400682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Enum")
400782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
400882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if(not $TypeAttr{"NameSpace"})
400982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
401082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            foreach my $Pos (keys(%{$TypeAttr{"Memb"}}))
401182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            {
401282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                my $MName = $TypeAttr{"Memb"}{$Pos}{"name"};
40138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $MVal = $TypeAttr{"Memb"}{$Pos}{"value"};
401482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                $EnumConstants{$Version}{$MName} = {
40158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    "Value"=>$MVal,
401682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                    "Header"=>$TypeAttr{"Header"}
401782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                };
40188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(isAnon($TypeAttr{"Name"}))
40198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
4020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($ExtraDump
4021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or is_target_header($TypeAttr{"Header"}, $Version))
4022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$Constants{$Version}{$MName}} = (
4024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Value" => $MVal,
4025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Header" => $TypeAttr{"Header"}
4026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        );
4027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
40288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
402982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            }
403082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
403182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
403274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
40334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
40344b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(defined $TypedefToAnon{$TypeId}) {
40354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr{"AnonTypedef"} = 1;
40364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
40374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
403882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
4039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
4040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub simplifyVTable($)
4043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
4044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Content = $_[0];
4045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Content=~s/ \[with (.+)]//)
4046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # std::basic_streambuf<_CharT, _Traits>::imbue [with _CharT = char, _Traits = std::char_traits<char>]
4047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my @Elems = separate_Params($1, 0, 0))
4048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Elem (@Elems)
4050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Elem=~/\A(.+?)\s*=\s*(.+?)\Z/)
4052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my ($Arg, $Val) = ($1, $2);
4054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $DEFAULT_STD_ARGS{$Arg}) {
4056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/,\s*$Arg\b//g;
4057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    else {
4059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/\b$Arg\b/$Val/g;
4060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
4065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Content;
4067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
4068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lang($)
4070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
4072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
407362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
40741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4 fncs-node points to only non-artificial methods
4075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Info=~/(fncs)[ ]*:[ ]*@(\d+) /);
4076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
40781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
407962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Fncs = getTreeAttr_Fncs($TypeId);
4080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Fncs)
4081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
408262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info"}{$Fncs}!~/artificial/) {
4083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
4084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
408562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Fncs = getTreeAttr_Chan($Fncs);
4086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
4089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setSpec($$)
4092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Info=~/\s+spec\s+/) {
4096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Spec"} = 1;
4097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
410062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub setBaseClasses($$)
4101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
410262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4104177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Binf = getTreeAttr_Binf($TypeId))
4105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4106177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Info = $LibInfo{$Version}{"info"}{$Binf};
4107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
4108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Info=~s/(pub|public|prot|protected|priv|private|)[ ]+binf[ ]*:[ ]*@(\d+) //)
4109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Access, $BInfoId) = ($1, $2);
4111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ClassId = getBinfClassId($BInfoId);
4112b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
41131b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            if($ClassId eq $TypeId)
4114b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            { # class A<N>:public A<N-1>
4115b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko                next;
4116b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            }
4117b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $CType = $LibInfo{$Version}{"info_type"}{$ClassId};
4119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CType or $CType eq "template_type_parm"
4120850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $CType eq "typename_type")
4121850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # skip
4122177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                # return 1;
4123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
4124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseInfo = $LibInfo{$Version}{"info"}{$BInfoId};
41254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($Access=~/prot/) {
4126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "protected";
4127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
41284b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            elsif($Access=~/priv/) {
4129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "private";
4130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
413101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr->{"Base"}{$ClassId}{"pos"} = "$Pos";
4132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseInfo=~/virt/)
41331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual base
4134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"virtual"} = 1;
4135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Class_SubClasses{$Version}{$ClassId}{$TypeId}=1;
41374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $Pos += 1;
4138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
4141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getBinfClassId($)
4144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$_[0]};
41463ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    if($Info=~/type[ ]*:[ ]*@(\d+) /) {
41473ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko        return $1;
41483ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    }
41493ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko
41503ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    return "";
4151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangledFormat($$)
4154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion) = @_;
4156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name = uncover_typedefs($Name, $LibVersion);
4157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Name=~s/([^\w>*])(const|volatile)(,|>|\Z)/$1$3/g){};
4158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\(\w+\)(\d)/$1/;
4159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
4160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub modelUnmangled($$)
4163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $Compiler) = @_;
4165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId}) {
4166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId};
4167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $PureSignature = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
4169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = "~".$PureSignature;
4171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Data"})
4173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@Params, @ParamTypes) = ();
4175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$Version}{$InfoId}{"Param"}
4176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$Version}{$InfoId}{"Param"}});
4178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"type"};
4182f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $PName = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"name"};
4183f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PType = get_PureType($PId, $TypeInfo{$Version});
4184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PTName = unmangledFormat($PType{"Name"}, $Version);
4185f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
4186f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($PName eq "this"
4187f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method")
4188f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
4189f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
4190f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
4191f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
419262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $PTName=~s/\b(restrict|register)\b//g;
4193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC") {
419462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $PTName=~s/\blong long\b/__int64/;
4195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @ParamTypes = (@ParamTypes, $PTName);
4197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@ParamTypes) {
4199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature .= "(".join(", ", @ParamTypes).")";
4200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC")
4204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
4205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "(void)";
4206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # GCC
4209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "()";
4210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = delete_keywords($PureSignature);
4213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
4215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
421662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ClassName = unmangledFormat($TypeInfo{$Version}{$ClassId}{"Name"}, $Version);
4217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $ClassName."::".$PureSignature;
4218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $NS = $SymbolInfo{$Version}{$InfoId}{"NameSpace"}) {
4220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $NS."::".$PureSignature;
4221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Const"}) {
4223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " const";
4224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Volatile"}) {
4226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " volatile";
4227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShowReturn = 0;
4229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "MSVC"
4230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Data"})
4231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
423462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(defined $TemplateInstance{$Version}{"Func"}{$InfoId}
423562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and keys(%{$TemplateInstance{$Version}{"Func"}{$InfoId}}))
4236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowReturn)
4240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled names for template function specializations include return value
4241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ReturnId = $SymbolInfo{$Version}{$InfoId}{"Return"})
4242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4243f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %RType = get_PureType($ReturnId, $TypeInfo{$Version});
4244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnName = unmangledFormat($RType{"Name"}, $Version);
4245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature = $ReturnName." ".$PureSignature;
4246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
42489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId} = formatName($PureSignature, "S"));
4249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_symbol($$$)
4252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # mangling for simple methods
4253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # see gcc-4.6.0/gcc/cp/mangle.c
4254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Compiler) = @_;
4255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler}) {
4256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler};
4257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = "";
4259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "GCC") {
42601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_GCC($InfoId, $LibVersion);
4261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Compiler eq "MSVC") {
42631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_MSVC($InfoId, $LibVersion);
4264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler} = $Mangled);
4266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_MSVC($$)
4269b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko{ # TODO
4270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_GCC($$)
4275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # see gcc-4.6.0/gcc/cp/mangle.c
4276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $ClassId, $NameSpace) = ("_Z", 0, "");
42781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
4279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Repl = ();# SN_ replacements
4280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
4281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledClass = mangle_param($ClassId, $LibVersion, \%Repl);
4283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledClass!~/\AN/) {
4284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass = "N".$MangledClass;
4285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/E\Z//;
4288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Volatile"}) {
4290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NV/;
4291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Const"}) {
4293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NK/;
4294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledClass;
4296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($NameSpace = $SymbolInfo{$LibVersion}{$InfoId}{"NameSpace"})
4298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled by name due to the absence of structured info
4299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = mangle_ns($NameSpace, $LibVersion, \%Repl);
4300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNS!~/\AN/) {
4301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS = "N".$MangledNS;
4302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS=~s/E\Z//;
4305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledNS;
4307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
430807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($SymbolInfo{$LibVersion}{$InfoId}{"ShortName"});
43091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my @TParams = ();
431035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if(my @TPos = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}}))
43111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # parsing mode
431235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        foreach (@TPos) {
431335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            push(@TParams, $SymbolInfo{$LibVersion}{$InfoId}{"TParam"}{$_}{"name"});
431435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
43151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
43161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    elsif($TmplParams)
43171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # remangling mode
43181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko      # support for old ABI dumps
431907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @TParams = separate_Params($TmplParams, 0, 0);
4320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"}) {
4322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "C1";
4323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "D0";
4326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ShortName)
4328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
43291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
43301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
43311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
4332850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and isConstType($Return, $LibVersion))
43331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # "const" global data is mangled as _ZL...
43341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Mangled .= "L";
43351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
43361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
4337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShortName=~/\Aoperator(\W.*)\Z/)
4338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Op = $1;
4340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Op=~s/\A[ ]+//g;
4341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $OpMngl = $OperatorMangling{$Op}) {
4342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= $OpMngl;
4343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else { # conversion operator
4345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= "cv".mangle_param(getTypeIdByName($Op, $LibVersion), $LibVersion, \%Repl);
4346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= length($ShortName).$ShortName;
4350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
43541477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko            foreach my $TParam (@TParams) {
4355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, \%Repl);
4356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ClassId and @TParams) {
4360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($ShortName, \%Repl, 0);
4361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId or $NameSpace) {
4364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4366850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(@TParams)
4367850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
43681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Return) {
4369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($Return, $LibVersion, \%Repl);
4370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
4373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = ();
4375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
4376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
4378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamType_Id = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$ParamPos}{"type"};
4382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($ParamType_Id, $LibVersion, \%Repl);
4383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = correct_incharge($InfoId, $LibVersion, $Mangled);
4389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = write_stdcxx_substitution($Mangled);
4390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mangled eq "_Z") {
4391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub correct_incharge($$$)
4397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Mangled) = @_;
4399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"})
4400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4402f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/C1([EI])/C2$1/;
4403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
4406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4408f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D0([EI])/D1$1/;
4409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4411f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D1([EI])/D2$1/;
4412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
441707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub template_Base($)
4418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # NOTE: std::_Vector_base<mysqlpp::mysql_type_info>::_Vector_impl
44191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko  # NOTE: operators: >>, <<
4420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
44211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Name!~/>\Z/ or $Name!~/</) {
4422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Name;
4423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TParams = $Name;
44251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($TParams, "<"))
44261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # search for the last <T>
4427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TParams = substr($TParams, $CPos);
4428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
44291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($TParams=~s/\A<(.+)>\Z/$1/) {
44301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Name=~s/<\Q$TParams\E>\Z//;
44311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
44321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    else
44331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # error
44341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TParams = "";
44351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $TParams);
4437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_ns($)
4440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
4442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @NS = ();
44431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($Name, ":"))
4444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@NS, substr($Name, 0, $CPos));
4446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name = substr($Name, $CPos);
4447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name=~s/\A:://;
4448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (join("::", @NS), $Name);
4450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_ns($$$)
4453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion, $Repl) = @_;
4455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Tid = $TName_Tid{$LibVersion}{$Name})
4456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Mangled = mangle_param($Tid, $LibVersion, $Repl);
4458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled=~s/\AN(.+)E\Z/$1/;
4459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Mangled;
4460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($MangledNS, $SubNS) = ("", "");
4465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($SubNS, $Name) = get_sub_ns($Name);
4466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($Name).$Name;
4470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        add_substitution($MangledNS, $Repl, 0);
4471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $MangledNS;
4472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_param($$$)
4476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($PTid, $LibVersion, $Repl) = @_;
4478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MPrefix, $Mangled) = ("", "");
4479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %ReplCopy = %{$Repl};
448062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType = get_BaseType($PTid, $LibVersion);
4481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $BaseType_Name = $BaseType{"Name"};
448274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $BaseType_Name=~s/\A(struct|union|enum) //g;
4483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $BaseType_Name) {
4484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
448607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($BaseType_Name);
448762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Suffix = get_BaseTypeQual($PTid, $LibVersion);
4488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~s/\s*(const|volatile|restrict)\Z//g){};
4489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~/(&|\*|const)\Z/)
4490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*&\Z//) {
4492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "R";
4493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*\*\Z//) {
4495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "P";
4496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*const\Z//)
4498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MPrefix=~/R|P/
4500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $Suffix=~/&|\*/) {
4501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MPrefix .= "K";
4502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*volatile\Z//) {
4505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "V";
4506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($Suffix=~s/[ ]*restrict\Z//) {
4508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #$MPrefix .= "r";
4509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
4510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Token = $IntrinsicMangling{$BaseType_Name}) {
4512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $Token;
4513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(Class|Struct|Union|Enum)/)
4515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
45161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my @TParams = ();
451735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if(my @TPos = keys(%{$BaseType{"TParam"}}))
45181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # parsing mode
451935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            foreach (@TPos) {
452035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                push(@TParams, $BaseType{"TParam"}{$_}{"name"});
452135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            }
45221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
45231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        elsif($TmplParams)
45241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # remangling mode
45251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # support for old ABI dumps
452607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            @TParams = separate_Params($TmplParams, 0, 0);
4527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = "";
4529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($SubNS, $SName) = get_sub_ns($ShortName);
4530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($SName).$SName;
4534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams) {
4535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($MangledNS, $Repl, 0);
4536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "N".$MangledNS;
4538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
4541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $TParam (@TParams) {
4542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, $Repl);
4543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(FuncPtr|MethodPtr)/)
4549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($BaseType{"Type"} eq "MethodPtr") {
4551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl)."F";
4552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "PF";
4555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = keys(%{$BaseType{"Param"}});
4558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (sort {int($a)<=>int($b)} @Params) {
4559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($BaseType{"Param"}{$Num}{"type"}, $LibVersion, $Repl);
4560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"} eq "FieldPtr")
4567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl);
4569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = $MPrefix.$Mangled;# add prefix (RPK)
4572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Optimized = write_substitution($Mangled, \%ReplCopy))
4573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Mangled eq $Optimized)
4575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ShortName!~/::/)
4577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # remove "N ... E"
4578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MPrefix) {
4579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\A($MPrefix)N(.+)E\Z/$1$2/g;
4580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
4582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\AN(.+)E\Z/$1/g;
4583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled = $Optimized;
4588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    add_substitution($Mangled, $Repl, 1);
4591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_template_param($$$)
4595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # types + literals
4596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TParam, $LibVersion, $Repl) = @_;
4597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $TPTid = $TName_Tid{$LibVersion}{$TParam}) {
4598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return mangle_param($TPTid, $LibVersion, $Repl);
4599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A(\d+)(\w+)\Z/)
4601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<1u>::method(...)
4602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$ConstantSuffixR{$2}}.$1."E";
4603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A\(([\w ]+)\)(\d+)\Z/)
4605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<(signed char)1>::method(...)
4606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$1}.$2."E";
4607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "true")
4609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb1E";
4611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "false")
4613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb0E";
4615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else { # internal error
4617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return length($TParam).$TParam;
4618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub add_substitution($$$)
4622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Value, $Repl, $Rec) = @_;
4624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Rec)
4625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # subtypes
4626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Subs = ($Value);
4627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Value=~s/\A(R|P|K)//) {
4628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Subs, $Value);
4629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (reverse(@Subs)) {
4631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($_, $Repl, 0);
4632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($Value=~/\AS(\d*)_\Z/);
4636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Value=~s/\AN(.+)E\Z/$1/g;
4637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(defined $Repl->{$Value});
4638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($Value)<=1);
4639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($StdcxxMangling{$Value});
4640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check for duplicates
4641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Base = $Value;
4642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Replace\E/$Type/;
4647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $OldNum = $Repl->{$Base})
4649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $OldNum;
4651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Repls = sort {$b<=>$a} values(%{$Repl});
4654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Repls) {
4655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $Repls[0]+1;
4656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
4658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = -1;
4659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # register duplicates
4661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # upward
4662dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Base = $Value;
4663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Base eq $Type);
4666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Type\E/$Replace/;
4669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Base} = $Repl->{$Value};
4670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub macro_mangle($)
4674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Num = $_[0];
4676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Num==-1) {
4677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S_";
4678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Code = "";
4682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num<10)
4683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S0_, S1_, S2_, ...
4684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num;
4685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Num>=10 and $Num<=35)
4687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SA_, SB_, SC_, ...
4688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = chr(55+$Num);
4689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S10_, S11_, S12_
4692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num-26; # 26 is length of english alphabet
4693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S".$Code."_";
4695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_stdcxx_substitution($)
4699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = $_[0];
4701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdcxxMangling{$Mangled}) {
4702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $StdcxxMangling{$Mangled};
4703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%StdcxxMangling);
4707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = $StdcxxMangling{$MangledType};
4711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #if($Mangled!~/$Replace/) {
4712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #}
4715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_substitution($$)
4721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $Repl) = @_;
4723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Repl->{$Mangled}
4724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $MnglNum = $Repl->{$Mangled}) {
4725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled = macro_mangle($MnglNum);
4726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%{$Repl});
4730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #@Repls = sort {$Repl->{$a}<=>$Repl->{$b}} @Repls;
4731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # FIXME: how to apply replacements? by num or by pos
4732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = macro_mangle($Repl->{$MangledType});
4736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mangled!~/$Replace/) {
4737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub delete_keywords($)
4746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
474862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeName=~s/\b(enum|struct|union|class) //g;
4749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TypeName;
4750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub uncover_typedefs($$)
4753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
4755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName);
4756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName}) {
4757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName};
4758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
47599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($TypeName_New, $TypeName_Pre) = (formatName($TypeName, "T"), "");
4760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName_New ne $TypeName_Pre)
4761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeName_Pre = $TypeName_New;
4763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeName_Copy = $TypeName_New;
4764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Words = ();
476562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($TypeName_Copy=~s/\b([a-z_]([\w:]*\w|))\b//io)
4766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
476762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Intrinsic_Keywords{$1}) {
476862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Words{$1} = 1;
476962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
4770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Word (keys(%Words))
4772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseType_Name = $Typedef_BaseName{$LibVersion}{$Word};
4774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $BaseType_Name);
477562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if($TypeName_New=~/\b(struct|union|enum)\s\Q$Word\E\b/);
4776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseType_Name=~/\([\*]+\)/)
4777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # FuncPtr
4778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TypeName_New=~/\Q$Word\E(.*)\Z/)
4779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
4780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Type_Suffix = $1;
4781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeName_New = $BaseType_Name;
4782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TypeName_New=~s/\(([\*]+)\)/($1 $Type_Suffix)/) {
47839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $TypeName_New = formatName($TypeName_New, "T");
4784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
4785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
478962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeName_New=~s/\b\Q$Word\E\b/$BaseType_Name/g) {
47909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $TypeName_New = formatName($TypeName_New, "T");
4791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"uncover_typedefs"}{$LibVersion}{$TypeName} = $TypeName_New);
4796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInternal($)
4799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4800989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
4801989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
4802989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /)
4803989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
4804989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/\*[ ]*INTERNAL[ ]*\*/)
4805989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # _ZN7mysqlpp8DateTimeC1ERKS0_ *INTERNAL*
4806989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return 1;
4807989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
4808989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
4809989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
4810989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
4811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getDataVal($$)
48140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/init[ ]*:[ ]*@(\d+) /)
48190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $LibInfo{$Version}{"info_type"}{$1}
48210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $LibInfo{$Version}{"info_type"}{$1} eq "nop_expr")
48228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
48238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $Nop = getTreeAttr_Op($1))
48240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
48258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(defined $LibInfo{$Version}{"info_type"}{$Nop}
48268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $LibInfo{$Version}{"info_type"}{$Nop} eq "addr_expr")
48270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
48288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(my $Addr = getTreeAttr_Op($1)) {
48298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return getInitVal($Addr, $TypeId);
48300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
48310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
48320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            else {
48350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getInitVal($1, $TypeId);
48360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
48420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getInitVal($$)
48430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$InfoId})
48480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($InfoType eq "integer_cst")
48500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
48510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Val = getNodeIntCst($InfoId);
485262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeId and $TypeInfo{$Version}{$TypeId}{"Name"}=~/\Achar(| const)\Z/)
48530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # characters
48540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Val = chr($Val);
48550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Val;
48570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($InfoType eq "string_cst") {
48590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getNodeStrCst($InfoId);
48600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
486101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($InfoType eq "var_decl")
486201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
486301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Name = getNodeStrCst(getTreeAttr_Mngl($InfoId))) {
486401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    return $Name;
486501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
486601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
48670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
4872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub set_Class_And_Namespace($)
4873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4875989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
4876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4877989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /)
4878dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
4879989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $NSInfoId = $1;
4880989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
4881989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
4882989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($InfoType eq "namespace_decl") {
4883989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"NameSpace"} = getNameSpace($InfoId);
4884989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4885989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($InfoType eq "record_type") {
4886989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Class"} = $NSInfoId;
4887989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4888dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
4889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Class"}
4892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"NameSpace"})
4893fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
4894570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($COMMON_LANGUAGE{$Version} ne "C++")
4895fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # skip
4896fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
4897570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
4898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
4900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
4901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub debugMangling($)
4904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
4906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Mangled = ();
4907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
4908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Mngl = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
4910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mngl=~/\A(_Z|\?)/) {
4912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled{$Mngl}=$InfoId;
4913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%Mangled), $LibVersion);
4917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Mngl (keys(%Mangled))
4918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U1 = modelUnmangled($Mangled{$Mngl}, "GCC");
4920850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U2 = $tr_name{$Mngl};
4921850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($U1 ne $U2) {
4922850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            printMsg("INFO", "INCORRECT MANGLING:\n  $Mngl\n  $U1\n  $U2\n");
4923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub linkSymbol($)
4928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # link symbols from shared libraries
4929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # with the symbols from header files
4930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to mangle symbol
493262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if((not check_gcc($GCC_PATH, "4") and $SymbolInfo{$Version}{$InfoId}{"Class"})
4933f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or (check_gcc($GCC_PATH, "4") and not $SymbolInfo{$Version}{$InfoId}{"Class"})
4934f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or $EMERGENCY_MODE_48)
4935f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # GCC 3.x doesn't mangle class methods names in the TU dump (only functions and global data)
4936f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.x doesn't mangle C++ functions in the TU dump (only class methods) except extern "C" functions
49378a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko      # GCC 4.8.[012] doesn't mangle anything
49381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CheckHeadersOnly)
4939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name_gcc{modelUnmangled($InfoId, "GCC")}) {
4941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return correct_incharge($InfoId, $Version, $Mangled);
4942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
49441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($CheckHeadersOnly
4945f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or not $BinaryOnly
4946f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or $EMERGENCY_MODE_48)
49471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # 1. --headers-only mode
49481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # 2. not mangled src-only symbols
49491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Mangled = mangle_symbol($InfoId, $Version, "GCC")) {
49501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return $Mangled;
49511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
49521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
4953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setLanguage($$)
4958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Lang) = @_;
4960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $UserLang) {
4961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{$LibVersion} = $Lang;
4962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo($)
4966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
49671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
4968989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isInternal($InfoId)) {
4969989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return;
4970989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
49711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
49721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
4973a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"}))
4974a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncAccess($InfoId);
49791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncKind($InfoId);
4980a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"PseudoTemplate"})
4981a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
498574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
49861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Type"} = getFuncType($InfoId);
4987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Return = getFuncReturn($InfoId))
498862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
4989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Return}
4990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Return}{"Name"})
4991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
499262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
499362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
499462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
4995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Return;
499662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
499762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
499862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
499962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
500062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
500162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
500262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
500362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
500462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
50061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Return"}) {
50071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5009a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Orig = getFuncOrig($InfoId);
5010a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getFuncShortName($Orig);
501174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "\._")!=-1)
501274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
501374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
501474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return;
501574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
501674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
501774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "tmp_add_func")==0)
5018a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5022a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
5023a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Func"}{$Orig})
5024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Tmpl = $BasicTemplate{$Version}{$InfoId};
5026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5027a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my @TParams = getTParams($Orig, "Func");
5028a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(not @TParams)
5029a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
50301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (0 .. $#TParams)
5034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Val = $TParams[$Pos];
5036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"TParam"}{$Pos}{"name"} = $Val;
5037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
5039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
5041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = $Val;
5043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Tmpl)
5048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
5050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Pos>$#TParams)
5052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
5054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = "";
5055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
50571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
50591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\Aoperator\W+\Z/)
50601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # operator<< <T>, operator>> <T>
50611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= " ";
50621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5063b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(@TParams) {
5064b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<".join(", ", @TParams).">";
5065b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
5066b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
5067b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<...>";
5068b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
50699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} = formatName($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "S");
5070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
5072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC 3.4
50731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5075f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
5076f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
5077f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
5078f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
5079f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
5080f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
5081f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
5082f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
5083f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # NOTE: mangling of some symbols may change depending on GCC version
5084f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.6: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2IT_EERKS_IT_E
5085f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.7: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2ERKS1_
5086f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
5087989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
50881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
50899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
5090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
50911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
50941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Destructor"})
5095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # destructors have an empty parameter list
50961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Skip = setFuncParams($InfoId);
509707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Skip)
509807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
50991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5103fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ artificial /i) {
5104fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Artificial"} = 1;
5105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(set_Class_And_Namespace($InfoId))
5108fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return;
5111fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
511362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
511462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5115177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
5116177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
5117177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
511862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
511962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
512062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
512162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
512235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
512335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
51241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
512535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5127dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
5128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
51291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
5132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # correct mangled & short names
51331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # C++ or --headers-only mode
51341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\A__(comp|base|deleting)_(c|d)tor\Z/)
5135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old GCC versions: reconstruct real names for constructors and destructors
51361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getNameByInfo(getTypeDeclId($SymbolInfo{$Version}{$InfoId}{"Class"}));
51371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
51391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
51411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(my $Mangled = linkSymbol($InfoId)) {
51421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
5143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
5146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # link MS C++ symbols from library with GCC symbols from headers
5147dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Mangled1 = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
5148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # exported symbols
5149dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled1;
5150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5151dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(my $Mangled2 = mangle_symbol($InfoId, $Version, "MSVC"))
5152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual symbols
5153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled2;
5154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
5158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # not mangled in C
5159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
51618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $CheckHeadersOnly
51628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function"
51638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and not $SymbolInfo{$Version}{$InfoId}{"Class"})
51648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
51658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Incorrect = 0;
51668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
51678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
51688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")==0
51708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
51718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # mangled in the TU dump, but not mangled in the library
51728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
51768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SymbolInfo{$Version}{$InfoId}{"Lang"} ne "C")
51788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # all C++ functions are not mangled in the TU dump
51798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Incorrect)
51838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(link_symbol($SymbolInfo{$Version}{$InfoId}{"ShortName"}, $Version, "-Deps")) {
51858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
51868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
51891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # can't detect symbol name
51911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5194989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Constructor"}
5195a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    and my $Spec = getVirtSpec($Orig))
5196989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # identify virtual and pure virtual functions
5197989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: constructors cannot be virtual
5198989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: in GCC 4.7 D1 destructors have no virtual spec
5199989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # in the TU dump, so taking it from the original symbol
5200989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not ($SymbolInfo{$Version}{$InfoId}{"Destructor"}
5201989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        and $SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/D2E/))
5202989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # NOTE: D2 destructors are not present in a v-table
5203989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{$Spec} = 1;
5204989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isInline($InfoId)) {
52071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"InLine"} = 1;
5208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
520982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if(hasThrow($InfoId)) {
5210e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Throw"} = 1;
5211e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
52121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
5214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"InLine"}
5216b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Artificial"})
5217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # inline or auto-generated constructor
521862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$Version}{$ClassId}{"Copied"});
5219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5221850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5222850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
5223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $ExtraDump)
5224570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
5225570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
5226570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # non-target symbols
5227570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5228570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return;
5229570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
5230850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
5231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method"
52331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Constructor"}
52341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}
52351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Class"})
5236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"}!~/\A(_Z|\?)/)
52389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
52391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
5244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # one instance for one mangled name only
52471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
52511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}} = 1;
5252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
52561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/
52591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Class"})
5260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function")
5262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # static methods
52631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncLink($InfoId) eq "Static") {
52671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5269dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/)
5270dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5271dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $Unmangled = $tr_name{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5272dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
52739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Unmangled=~/\.\_\d/)
52749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
5275dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5276dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return;
5277dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5278dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5280f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
52811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(V|)K/) {
52821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(K|)V/) {
52851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
528707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
528807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($WeakSymbols{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}}) {
528907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Weak"} = 1;
529007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
529174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
529274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
529374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
529474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
529574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
529674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
529774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub guessHeader($)
529874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
529974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
530074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ShortName = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
530174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"};
530274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassName = $ClassId?get_ShortClass($ClassId, $Version):"";
530374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Header = $SymbolInfo{$Version}{$InfoId}{"Header"};
530474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $HPath = $SymbolHeader{$Version}{$ClassName}{$ShortName})
530574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
530674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(get_filename($HPath) eq $Header)
530774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
530874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $HDir = get_filename(get_dirname($HPath));
530974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($HDir ne "include"
531074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $HDir=~/\A[a-z]+\Z/i) {
531174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HDir, $Header);
531274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
531374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
531474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
531574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Header;
5316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInline($)
5319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # "body: undefined" in the tree
5320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # -fkeep-inline-functions GCC option should be specified
5321dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5322dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5323dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ undefined /i) {
5324dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return 0;
5325dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
5328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5330e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub hasThrow($)
5331e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5332e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5333e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5334e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5335e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return getTreeAttr_Unql($1, "unql");
5336e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5337e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5338e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return 1;
5339e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5340e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
5341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeId($)
5342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5343dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5344dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5345dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5346dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5347dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5349dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeMemb($$)
5353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeType = $TypeAttr->{"Type"};
53560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $UnnamedPos) = (0, 0);
535774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $StaticFields = 0;
5358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeType eq "Enum")
5359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53604b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Csts($TypeId);
53614b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53634b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"value"} = getEnumMembVal($MInfoId);
53644b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembName = getTreeStr(getTreeAttr_Purp($MInfoId));
536562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $MembName;
53664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $EnumMembName_Id{$Version}{getTreeAttr_Valu($MInfoId)} = ($TypeAttr->{"NameSpace"})?$TypeAttr->{"NameSpace"}."::".$MembName:$MembName;
53674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
53680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeType=~/\A(Struct|Class|Union)\Z/)
5372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53734b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Flds($TypeId);
53744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53764b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $IType = $LibInfo{$Version}{"info_type"}{$MInfoId};
53774b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MInfo = $LibInfo{$Version}{"info"}{$MInfoId};
5378989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $IType or $IType ne "field_decl")
5379989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # search for fields, skip other stuff in the declaration
538074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
538174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($IType eq "var_decl")
538274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # static field
538374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $StaticFields = 1;
538474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
538574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
53864b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
53894b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $StructMembName = getTreeStr(getTreeAttr_Name($MInfoId));
5390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(index($StructMembName, "_vptr.")==0)
53911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual tables
5392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $StructMembName = "_vptr";
5393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields
539601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($TypeAttr->{"Name"}, "_type_info_pseudo")==-1)
5397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
53984b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    my $UnnamedTid = getTreeAttr_Type($MInfoId);
5399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $UnnamedTName = getNameByInfo(getTypeDeclId($UnnamedTid));
5400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isAnon($UnnamedTName))
5401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # rename unnamed fields to unnamed0, unnamed1, ...
5402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $StructMembName = "unnamed".($UnnamedPos++);
5403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
5404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
5405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields and base classes
54084b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54114b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembTypeId = getTreeAttr_Type($MInfoId);
541262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $MissedTypedef{$Version}{$MembTypeId})
541362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
541462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $AddedTid = $MissedTypedef{$Version}{$MembTypeId}{"Tid"}) {
541562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $MembTypeId = $AddedTid;
541662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
5417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
54190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"type"} = $MembTypeId;
54200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $StructMembName;
54214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if((my $Access = getTreeAccess($MInfoId)) ne "public")
54221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # marked only protected and private, public by default
54230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"access"} = $Access;
54240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
54250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($MInfo=~/spec:\s*mutable /)
54260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # mutable fields
54270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"mutable"} = 1;
5428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $Algn = getAlgn($MInfoId)) {
5430f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"algn"} = $Algn;
5431f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
54324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $BFSize = getBitField($MInfoId))
5433f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bits
54340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"bitfield"} = $BFSize;
5435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
5437f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bytes
5438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($TypeAttr->{"Memb"}{$Pos}{"algn"}==1)
5439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                { # template
5440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($TypeAttr->{"Memb"}{$Pos}{"algn"});
5441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                else {
5443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeAttr->{"Memb"}{$Pos}{"algn"} /= $BYTE_SIZE;
5444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5446f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
54474b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
54480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
545174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
545274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $StaticFields;
5453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncParams($)
5456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
54571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
545862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamInfoId = getTreeAttr_Args($InfoId);
5459f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5460f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5461f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5462f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check type of "this" pointer
546462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjectTypeId = getTreeAttr_Type($ParamInfoId);
546562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ObjectName = $TypeInfo{$Version}{$ObjectTypeId}{"Name"})
5466850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
546762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bconst(| volatile)\*const\b/) {
5468850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5469850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
547062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bvolatile\b/) {
5471850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5472850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
5473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5474850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else
5475850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # skip
5476850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
5477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5478ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # skip "this"-parameter
5479ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # $ParamInfoId = getNextElem($ParamInfoId);
5480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5481f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos, $Vtt_Pos) = (0, 0, -1);
5482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamInfoId)
54830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # formal args
548462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Type($ParamInfoId);
548562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamName = getTreeStr(getTreeAttr_Name($ParamInfoId));
548662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $ParamName)
548762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # unnamed
5488f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $ParamName = "p".($PPos+1);
5489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
549062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$ParamTypeId})
549162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
549262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$ParamTypeId}{"Tid"}) {
549362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ParamTypeId = $AddedTid;
549462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
549562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
549662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PType = $TypeInfo{$Version}{$ParamTypeId}{"Type"};
5497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $PType or $PType eq "Unknown") {
5498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
5499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
550062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PTName = $TypeInfo{$Version}{$ParamTypeId}{"Name"};
5501989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $PTName) {
5502989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return 1;
5503989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5504989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($PTName eq "void") {
5505989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            last;
5506989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ParamName eq "__vtt_parm"
550862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void const**")
5509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
55100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Vtt_Pos = $Pos;
5511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamInfoId = getNextElem($ParamInfoId);
5512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
55140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
5515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my %Base = get_BaseType($ParamTypeId, $Version))
5517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5518177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Base{"Template"}) {
5519177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
5520177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
55230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = $ParamName;
552462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Algn = getAlgn($ParamInfoId)) {
552562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"algn"} = $Algn/$BYTE_SIZE;
552662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info"}{$ParamInfoId}=~/spec:\s*register /)
5528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # foo(register type arg)
55290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"reg"} = 1;
5530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamInfoId = getNextElem($ParamInfoId);
55320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5533f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($ParamName ne "this" or $FType ne "Method") {
5534f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5535f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
5536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(setFuncArgs($InfoId, $Vtt_Pos)) {
553801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = "-1";
5539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
5541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub setFuncArgs($$)
5544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
55451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($InfoId, $Vtt_Pos) = @_;
55461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $FuncTypeId = getFuncTypeId($InfoId);
554762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamListElemId = getTreeAttr_Prms($FuncTypeId);
5548f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5549f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5550f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5551f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
5552f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        # skip "this"-parameter
555346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        # $ParamListElemId = getNextElem($ParamListElemId);
5554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $ParamListElemId)
55560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # foo(...)
55570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
55580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
5559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HaveVoid = 0;
5560f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos) = (0, 0);
5561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamListElemId)
55620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # actual params: may differ from formal args
55630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # formal int*const
55640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # actual: int*
55650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Vtt_Pos!=-1 and $Pos==$Vtt_Pos)
5566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Vtt_Pos=-1;
5568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamListElemId = getNextElem($ParamListElemId);
5569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
557162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Valu($ParamListElemId);
557262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void")
5573dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $HaveVoid = 1;
5575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
5576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
557746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        else
5578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
557946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            if(not defined $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
558046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
558146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
558246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"})
558346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # unnamed
5584f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($PPos+1);
558546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
558646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            }
558746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            elsif(my $OldId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
558846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
5589e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if($Pos>0 or getFuncType($InfoId) ne "Method")
559046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # params
559146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    if($OldId ne $ParamTypeId)
559246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    {
559346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %Old_Pure = get_PureType($OldId, $TypeInfo{$Version});
559446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %New_Pure = get_PureType($ParamTypeId, $TypeInfo{$Version});
559546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko
559646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($Old_Pure{"Name"} ne $New_Pure{"Name"}) {
559746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
559846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
559946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    }
560046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
56010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
56020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
560362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $PurpId = getTreeAttr_Purp($ParamListElemId))
56040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # default arguments
560501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $PurpType = $LibInfo{$Version}{"info_type"}{$PurpId})
560601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
56078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($PurpType eq "nop_expr")
56088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # func ( const char* arg = (const char*)(void*)0 )
56098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $PurpId = getTreeAttr_Op($PurpId);
56108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
561101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                my $Val = getInitVal($PurpId, $ParamTypeId);
561201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(defined $Val) {
561301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"default"} = $Val;
561401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
5615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamListElemId = getNextElem($ParamListElemId);
5618f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Pos!=0 or $FType ne "Method") {
5619f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5620f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
56210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ($Pos>=1 and not $HaveVoid);
5624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
562662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chan($)
562762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
562862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
562962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
563062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chan[ ]*:[ ]*@(\d+) /) {
563162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
563262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
563362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
563462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
563562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
563662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
563762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chain($)
563862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
563962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
564062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
564162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chain[ ]*:[ ]*@(\d+) /) {
564262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
564362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
564462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
564562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
564662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
564762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5648e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub getTreeAttr_Unql($)
5649e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5650e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5651e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5652e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*@(\d+) /) {
5653e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return $1;
5654e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5655e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5656e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return "";
5657e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5658e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
565962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Scpe($)
566062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
566162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
566262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
566362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /) {
566462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
566562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
566662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
566762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
566862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
566962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
567062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Type($)
567162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
567262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
567362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
567462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
567562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
567662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
567762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
567862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
567962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
568062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
568162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Name($)
568262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
568362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
568462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
568562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /) {
568662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
568762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
568862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
568962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
569062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
569162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
569262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Mngl($)
569362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
569462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
569562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
569662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /) {
569762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
569862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
569962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
570062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
570162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
570262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
570362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Prms($)
570462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
570562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
570662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
570762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/prms[ ]*:[ ]*@(\d+) /) {
570862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
570962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
571062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
571162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
571262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
571362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
571462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Fncs($)
5715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5716dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5717dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
571862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/fncs[ ]*:[ ]*@(\d+) /) {
571962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
572062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
572162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
572262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
572362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
572462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
572562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Csts($)
572662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
572762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
572862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
572962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/csts[ ]*:[ ]*@(\d+) /) {
573062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
573162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
573262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
573362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
573462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
573562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
573662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Purp($)
573762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
573862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
573962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
574062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
574162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
574262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
574362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
574462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
574562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
574662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
57478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getTreeAttr_Op($)
57488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
57498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
57508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
57518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Info=~/op 0[ ]*:[ ]*@(\d+) /) {
57528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return $1;
57538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
57548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
57558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return "";
57568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
57578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
575862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Valu($)
575962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
576062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
576162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
576262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
576362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
576462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
576562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
576662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
576762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
576862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
576962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Flds($)
577062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
577162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
577262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
577362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/flds[ ]*:[ ]*@(\d+) /) {
577462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
577562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
577662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
577762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
577862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
577962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5780177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getTreeAttr_Binf($)
5781177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
5782177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5783177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
5784177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Info=~/binf[ ]*:[ ]*@(\d+) /) {
5785177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $1;
5786177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5787177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
5788177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "";
5789177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
5790177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
579162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Args($)
579262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
579362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
579462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
579562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/args[ ]*:[ ]*@(\d+) /) {
5796dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5797dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeValue($)
5803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5804dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5805dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
58063ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko        if($Info=~/(low|int)[ ]*:[ ]*([^ ]+) /) {
58073ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko            return $2;
5808dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeAccess($)
5814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5815dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5817dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/accs[ ]*:[ ]*([a-zA-Z]+) /)
5818dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5819dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            my $Access = $1;
5820dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Access eq "prot") {
5821dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "protected";
5822dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5823dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($Access eq "priv") {
5824dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "private";
5825dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5826dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5827dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ protected /)
5828dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "protected";
5830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5831dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ private /)
5832dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "private";
5834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "public";
5837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncAccess($)
5840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
58411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Access = getTreeAccess($_[0]);
5842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
58431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Protected"} = 1;
5844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
58461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Private"} = 1;
5847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeAccess($$)
5851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Access = getTreeAccess($TypeId);
5854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
5855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Protected"} = 1;
5856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
5858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Private"} = 1;
5859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncKind($)
5863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5864dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5865dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5866dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/pseudo tmpl/) {
5867dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"PseudoTemplate"} = 1;
5868dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5869dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ constructor /) {
5870dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Constructor"} = 1;
5871dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5872dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ destructor /) {
5873dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Destructor"} = 1;
5874dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5878989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub getVirtSpec($)
5879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5880dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5881dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5882dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/spec[ ]*:[ ]*pure /) {
5883dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5884dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5885dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/spec[ ]*:[ ]*virt /) {
5886dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5887dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5888dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ pure\s+virtual /)
5889dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5890dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5891dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5892dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ virtual /)
5893dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5894dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5895dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncLink($)
5901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5902dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5903dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5904dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/link[ ]*:[ ]*static /) {
5905dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Static";
5906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5907dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/link[ ]*:[ ]*([a-zA-Z]+) /) {
5908dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5911dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
591474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Symbol_NS($$)
5915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
591674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
591774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "" if(not $Symbol or not $LibVersion);
591874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $NS = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
591974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $NS)
592074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
592174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(my $Class = $CompleteSignature{$LibVersion}{$Symbol}{"Class"}) {
592274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $NS = $TypeInfo{$LibVersion}{$Class}{"NameSpace"};
592374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
5924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
592574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($NS)
5926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
592774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
592874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
592974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
593074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
593274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
593374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
593474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
593574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
593674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
594074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
594174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
594474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Type_NS($$)
5945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
5947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName or not $LibVersion);
594874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NS = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$TypeName}}{"NameSpace"})
5949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
595074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
595174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
595274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
595374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
595574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
595674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
595774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
595874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
595974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
596374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameSpace($)
5967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
596874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
596974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NSInfoId = getTreeAttr_Scpe($InfoId))
5970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
597162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
5972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
597362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($InfoType eq "namespace_decl")
5974dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
597562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($LibInfo{$Version}{"info"}{$NSInfoId}=~/name[ ]*:[ ]*@(\d+) /)
597662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
597762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $NameSpace = getTreeStr($1);
597862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($NameSpace eq "::")
597962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # global namespace
598062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "";
598162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
598262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BaseNameSpace = getNameSpace($NSInfoId)) {
598362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NameSpace = $BaseNameSpace."::".$NameSpace;
598462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
598562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $NestedNameSpaces{$Version}{$NameSpace} = 1;
598662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return $NameSpace;
598762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
598862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
598962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return "";
5990dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
5991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            elsif($InfoType ne "function_decl")
599362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # inside data type
599462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($Name, $NameNS) = getTrivialName(getTypeDeclId($NSInfoId), $NSInfoId);
599562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Name;
599662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
5997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5999dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getEnumMembVal($)
6003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6004dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6006dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*\@(\d+)/)
6007dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
6008dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $VInfo = $LibInfo{$Version}{"info"}{$1})
6009dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
6010dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($VInfo=~/cnst[ ]*:[ ]*\@(\d+)/)
6011dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # in newer versions of GCC the value is in the "const_decl->cnst" node
6012dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6013dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6014dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                else
6015dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # some old versions of GCC (3.3) have the value in the "integer_cst" node
6016dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6017dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6018dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSize($)
6025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6027dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/size[ ]*:[ ]*\@(\d+)/) {
6029dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getTreeValue($1);
6030dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6032dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAlgn($)
6036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6037dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6038dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6039dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/algn[ ]*:[ ]*(\d+) /) {
6040dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6041dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6043dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6046f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getBitField($)
6047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6048dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6049dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6050dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ bitfield /) {
6051dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getSize($_[0]);
6052dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6054dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
605762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getNextElem($)
6058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
605962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Chan = getTreeAttr_Chan($_[0])) {
606062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chan;
6061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
606262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(my $Chain = getTreeAttr_Chain($_[0])) {
606362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chain;
6064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6065dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
606862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub registerHeader($$)
606962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # input: absolute path of header, relative path or name
6070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
607162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
607262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
6073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
607462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
607562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
607662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$Header\'");
6077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
607862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(skipHeader($Header, $LibVersion))
607962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # skip
6080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
6081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
608262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Header_Path = identifyHeader($Header, $LibVersion))
608362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
608462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        detect_header_includes($Header_Path, $LibVersion);
608562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
60868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(defined $Tolerance and $Tolerance=~/3/)
60878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # 3 - skip headers that include non-Linux headers
60888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($OSgroup ne "windows")
60898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
60908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Inc (keys(%{$Header_Includes{$LibVersion}{$Header_Path}}))
60918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
60928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(specificHeader($Inc, "windows")) {
60938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        return "";
60948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
60958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
60968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
60978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
60988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
609962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RHeader_Path = $Header_ErrorRedirect{$LibVersion}{$Header_Path})
610062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # redirect
610162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Registered_Headers{$LibVersion}{$RHeader_Path}{"Identity"}
610262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            or skipHeader($RHeader_Path, $LibVersion))
610362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # skip
610462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return "";
610562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
610662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Header_Path = $RHeader_Path;
610762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
610862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Header_ShouldNotBeUsed{$LibVersion}{$Header_Path})
610962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip
611062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "";
611162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
611262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
611362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HName = get_filename($Header_Path))
611462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # register
611562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Registered_Headers{$LibVersion}{$Header_Path}{"Identity"} = $HName;
611662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HeaderName_Paths{$LibVersion}{$HName}{$Header_Path} = 1;
611762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
611862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
611962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(($Header=~/\.(\w+)\Z/ and $1 ne "h")
612062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Header!~/\.(\w+)\Z/)
61218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # hpp, hh, etc.
612262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            setLanguage($LibVersion, "C++");
61238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CPP_HEADERS = 1;
612462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
612562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
612662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CheckHeadersOnly
612762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Header=~/(\A|\/)c\+\+(\/|\Z)/)
612862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # /usr/include/c++/4.6.1/...
612962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $STDCXX_TESTING = 1;
613062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
613162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
613262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header_Path;
6133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
613462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
6135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub registerDir($$$)
6138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $WithDeps, $LibVersion) = @_;
6140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//g;
6141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not $Dir or not -d $Dir);
6142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir = get_abs_path($Dir);
6143f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mode = "All";
6145850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($WithDeps)
6146850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}) {
6148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RegisteredDirs{$LibVersion}{$Dir}{0}) {
6151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mode = "DepsOnly";
6152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6154850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
6155850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}
6157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $RegisteredDirs{$LibVersion}{$Dir}{0}) {
6158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Header_Dependency{$LibVersion}{$Dir} = 1;
6162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $RegisteredDirs{$LibVersion}{$Dir}{$WithDeps} = 1;
6163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mode eq "DepsOnly")
6164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6165570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (cmd_find($Dir,"d")) {
6166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Dependency{$LibVersion}{$Path} = 1;
6167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
6169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6170570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (sort {length($b)<=>length($a)} cmd_find($Dir,"f"))
6171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($WithDeps)
6173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $SubDir = $Path;
6175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while(($SubDir = get_dirname($SubDir)) ne $Dir)
6176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # register all sub directories
6177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Dependency{$LibVersion}{$SubDir} = 1;
6178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(is_not_header($Path));
6181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
6182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Neighbors
61839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $Part (get_prefixes($Path)) {
6184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Neighbors{$LibVersion}{$Part} = $Path;
6185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_filename($Dir) eq "include")
6188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for "lib/include/" directory
6189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $LibDir = $Dir;
6190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibDir=~s/([\/\\])include\Z/$1lib/g and -d $LibDir) {
61918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($LibDir, $WithDeps, $LibVersion);
6192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_redirect($$$)
6197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path, $LibVersion) = @_;
6199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Errors = ();
6200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Content=~s/#\s*error\s+([^\n]+?)\s*(\n|\Z)//) {
6201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Errors, $1);
6202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Redirect = "";
6204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Errors)
6205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        s/\s{2,}/ /g;
6207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/(only|must\ include
6208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |update\ to\ include
6209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ with
6210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ by|renamed\ to
62119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        |\ is\ in|\ use)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))/ix)
6212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/(include|use|is\ in)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))\ instead/i)
6217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/this\ header\ should\ not\ be\ used
6222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |programs\ should\ not\ directly\ include
6223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |you\ should\ not\ (include|be\ (including|using)\ this\ (file|header))
6224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |is\ not\ supported\ API\ for\ general\ use
6225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |do\ not\ use
62269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko         |should\ not\ be\ (used|using)
6227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |cannot\ be\ included\ directly/ix and not /\ from\ /i) {
6228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
6229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6231850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Redirect)
6232850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6233850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/\A<//g;
6234850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/>\Z//g;
6235850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6236850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return $Redirect;
6237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_includes($$)
6240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path) = @_;
6242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Includes = ();
624374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]*([<"].+?[">])[ \t]*//m)
6244850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # C/C++: include, Objective C/C++: import directive
62454b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $Header = $2;
624674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $Method = substr($Header, 0, 1, "");
624774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        substr($Header, length($Header)-1, 1, "");
624874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Header = path_format($Header, $OSgroup);
624974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Method eq "\"" or is_abs($Header))
625074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
625174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-e join_P(get_dirname($Path), $Header))
625274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # relative path exists
625374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = -1;
6254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
625574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            else
625674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # include "..." that doesn't exist is equal to include <...>
625774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = 2;
6258850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
626074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else {
626174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$Header} = 1;
626274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
626374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
626474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
626574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
626674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]+(\w+)[ \t]*//m)
626774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # FT_FREETYPE_H
626874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$2} = 0;
6269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Includes;
6272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ignore_path($)
6275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\~\Z/)
6278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping system backup files
6279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/(\A|[\/\\]+)(\.(svn|git|bzr|hg)|CVS)([\/\\]+|\Z)/)
6282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping hidden .svn, .git, .bzr, .hg and CVS directories
6283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortByWord($$)
6289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $W) = @_;
6291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($W)<2);
6292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_filename($b)=~/\Q$W\E/i<=>get_filename($a)=~/\Q$W\E/i} @{$ArrRef};
6293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortHeaders($$)
6296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($H1, $H2) = @_;
62988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H1=~s/\.[a-z]+\Z//ig;
6300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H2=~s/\.[a-z]+\Z//ig;
63018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname1 = get_filename($H1);
63038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname2 = get_filename($H2);
63048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir1 = get_dirname($H1);
63058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir2 = get_dirname($H2);
6306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname1 = get_filename($HDir1);
6307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname2 = get_filename($HDir2);
63088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir1=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir2=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
63118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
63129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[0] eq $_[1]
63139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    or $H1 eq $H2) {
6314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H1=~/\A\Q$H2\E/) {
6317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H2=~/\A\Q$H1\E/) {
6320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir1=~/\Q$Hname1\E/i
6323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir2!~/\Q$Hname2\E/i)
63249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir2=~/\Q$Hname2\E/i
6328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir1!~/\Q$Hname1\E/i)
63299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname1=~/\Q$Dirname1\E/i
6333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname2!~/\Q$Dirname2\E/i)
63349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname2=~/\Q$Dirname2\E/i
6338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname1!~/\Q$Dirname1\E/i)
63399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname1=~/(config|lib|util)/i
63439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname2!~/(config|lib|util)/i)
63449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname2=~/(config|lib|util)/i
63489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname1!~/(config|lib|util)/i)
63499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
63539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
63548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R1 = checkRelevance($H1);
63558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R2 = checkRelevance($H2);
63568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($R1 and not $R2)
63578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return -1;
63598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        elsif($R2 and not $R1)
63618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
63638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
63658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
63668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return (lc($H1) cmp lc($H2));
63678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
6368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub searchForHeaders($)
6372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
6374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # gcc standard include paths
6376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    registerGccHeaders();
6377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6378570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" and not $STDCXX_TESTING)
6379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # c++ standard include paths
6380570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        registerCppHeaders();
6381570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing header paths
6384570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$Descriptor{$LibVersion}{"IncludePaths"}},
6385570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    @{$Descriptor{$LibVersion}{"AddIncludePaths"}})
6386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IPath = $Path;
6388a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($SystemRoot)
6389a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
6390a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(is_abs($Path)) {
6391a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Path = $SystemRoot.$Path;
6392a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
6393a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        }
6394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Path) {
6395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Path\'");
6396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path) {
6398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "\'$Path\' - not a directory");
6399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Path)
6401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = get_abs_path($Path);
64038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 0, $LibVersion);
6404570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(grep {$IPath eq $_} @{$Descriptor{$LibVersion}{"AddIncludePaths"}}) {
6405570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Add_Include_Paths{$LibVersion}}, $Path);
6406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
6408570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Include_Paths{$LibVersion}}, $Path);
6409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6412570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$Include_Paths{$LibVersion}}) {
6413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $INC_PATH_AUTODETECT{$LibVersion} = 0;
6414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6415570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering directories
6417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -e $Path);
6420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
6421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
6422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path) {
64238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 1, $LibVersion);
6424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path)
6426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($Path);
6428570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not grep { $Dir eq $_ } (@{$SystemPaths{"include"}})
6429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $LocalIncludes{$Dir})
6430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
64318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                registerDir($Dir, 1, $LibVersion);
6432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # if(my $OutDir = get_dirname($Dir))
6433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # { # registering the outer directory
6434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     if(not grep { $OutDir eq $_ } (@{$SystemPaths{"include"}})
6435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     and not $LocalIncludes{$OutDir}) {
6436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #         registerDir($OutDir, 0, $LibVersion);
6437fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     }
6438fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # }
6439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6442850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6443850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6444850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %RegisteredDirs = ();
6445850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering headers
6447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Position = 0;
6448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Dest) and not -e $Dest) {
6451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
6452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest = path_format($Dest, $OSgroup);
6454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_header($Dest, 1, $LibVersion))
6455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
645662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HPath = registerHeader($Dest, $LibVersion)) {
6457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$HPath}{"Pos"} = $Position++;
6458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Dest)
6461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Registered = ();
6463570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"f"))
6464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
6466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(not is_header($Path, 0, $LibVersion));
646762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $HPath = registerHeader($Path, $LibVersion)) {
6468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Registered, $HPath);
6469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
64719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            @Registered = sort {sortHeaders($a, $b)} @Registered;
64729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            sortByWord(\@Registered, $TargetLibraryShortName);
6473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (@Registered) {
6474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$Path}{"Pos"} = $Position++;
6475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
6478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't identify \'$Dest\' as a header file");
6479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
64828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/4/)
64838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 4 - skip headers included by others
64848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
64858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
6486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Header_Includes_R{$LibVersion}{$Path}) {
64878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($Registered_Headers{$LibVersion}{$Path});
64888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
64898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
64908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
64918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6492dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $HList = $Descriptor{$LibVersion}{"IncludePreamble"})
6493dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # preparing preamble headers
6494dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, $HList))
6495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6496dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(is_abs($Header) and not -f $Header) {
6497dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$Header\'");
6498dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6499dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Header = path_format($Header, $OSgroup);
6500dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Header_Path = is_header($Header, 1, $LibVersion))
6501dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
650262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(skipHeader($Header_Path, $LibVersion));
6503570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($Include_Preamble{$LibVersion}, $Header_Path);
6504dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6505dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else {
6506dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't identify \'$Header\' as a header file");
6507dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Header_Name (keys(%{$HeaderName_Paths{$LibVersion}}))
6511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # set relative paths (for duplicates)
6512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})>=2)
6513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for duplicates
6514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $FirstPath = (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))[0];
6515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Prefix = get_dirname($FirstPath);
6516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while($Prefix=~/\A(.+)[\/\\]+[^\/\\]+\Z/)
6517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # detect a shortest distinguishing prefix
6518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $NewPrefix = $1;
6519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my %Identity = ();
6520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
6522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Path=~/\A\Q$Prefix\E[\/\\]+(.*)\Z/) {
6523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Identity{$Path} = $1;
6524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(keys(%Identity)==keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
65276fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko                { # all names are different with current prefix
6528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})) {
6529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Registered_Headers{$LibVersion}{$Path}{"Identity"} = $Identity{$Path};
6530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
6532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Prefix = $NewPrefix; # increase prefix
6534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6537850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6538850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6539850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %HeaderName_Paths = ();
6540850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (keys(%{$Include_Order{$LibVersion}}))
6542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ordering headers according to descriptor
65438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $PairName = $Include_Order{$LibVersion}{$HeaderName};
6544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Pos, $PairPos) = (-1, -1);
6545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Path, $PairPath) = ();
6546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = keys(%{$Registered_Headers{$LibVersion}});
6547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Paths = sort {int($Registered_Headers{$LibVersion}{$a}{"Pos"})<=>int($Registered_Headers{$LibVersion}{$b}{"Pos"})} @Paths;
6548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header_Path (@Paths)
6549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $PairName)
6551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPath = $Header_Path;
6554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $HeaderName)
6556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Pos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Header_Path;
6559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PairPos!=-1 and $Pos!=-1
6562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and int($PairPos)<int($Pos))
6563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Tmp = %{$Registered_Headers{$LibVersion}{$Path}};
6565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$Path}} = %{$Registered_Headers{$LibVersion}{$PairPath}};
6566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$PairPath}} = %Tmp;
6567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Registered_Headers{$LibVersion}})) {
6570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "header files are not found in the ".$Descriptor{$LibVersion}{"Version"});
6571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_real_includes($$)
6575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $LibVersion or not $AbsPath or not -e $AbsPath);
6578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}
6579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6582850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}=1;
6583850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = callPreprocessor($AbsPath, "", $LibVersion);
6585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path);
6586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    open(PREPROC, $Path);
6587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(<PREPROC>)
6588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/#\s+\d+\s+"([^"]+)"[\s\d]*\n/)
6590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Include = path_format($1, $OSgroup);
6592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include=~/\<(built\-in|internal|command(\-|\s)line)\>|\A\./) {
6593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include eq $AbsPath) {
6596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$Include} = 1;
6599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
6602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_header_includes($$)
6606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
6608850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $LibVersion or not $Path);
6609850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"detect_header_includes"}{$LibVersion}{$Path}) {
6610850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6611850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6612850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_header_includes"}{$LibVersion}{$Path}=1;
6613850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6614850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not -e $Path) {
6615850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6616850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6617850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($Path);
6619850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Redirect = parse_redirect($Content, $Path, $LibVersion))
6620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # detect error directive in headers
662162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RedirectPath = identifyHeader($Redirect, $LibVersion))
6622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath=~/\/usr\/include\// and $Path!~/\/usr\/include\//) {
662462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $RedirectPath = identifyHeader(get_filename($Redirect), $LibVersion);
6625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath ne $Path) {
6627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_ErrorRedirect{$LibVersion}{$Path} = $RedirectPath;
6628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
66309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
66319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # can't find
66329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
66339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
6634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6635850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Inc = parse_includes($Content, $Path))
6636850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Include (keys(%{$Inc}))
6638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # detect includes
6639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Header_Includes{$LibVersion}{$Path}{$Include} = $Inc->{$Include};
66408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
66418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Tolerance and $Tolerance=~/4/)
66428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
66438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $HPath = identifyHeader($Include, $LibVersion))
66448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
66458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Header_Includes_R{$LibVersion}{$HPath}{$Path} = 1;
66468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
66478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
6648850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
6649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub fromLibc($)
665374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC header
6654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $Name) = separate_path($Path);
6656fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($Dir) eq "libc" and $GlibcHeader{$Name})
6659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{stdio, ...}.h
6660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Dir eq "/usr/include" and $GlibcHeader{$Name})
6666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{stdio, ...}.h
6667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLibcDir($)
667474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC directory
6675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
6676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($OutDir, $Name) = separate_path($Dir);
6677fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($OutDir) eq "libc"
6680fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6681fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{sys,bits,asm,asm-*}/*.h
6682fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6683fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6685fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6686fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # linux
6687fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($OutDir eq "/usr/include"
6688fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6689fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{sys,bits,asm,asm-*}/*.h
6690fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6691fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_recursive_includes($$)
6697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath);
6700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isCyclical(\@RecurInclude, $AbsPath)) {
6701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsDir, $Name) = separate_path($AbsPath);
6704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isLibcDir($AbsDir))
670574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # system GLIBC internals
670674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return () if(not $ExtraInfo);
6707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($OSgroup ne "windows" and $Name=~/windows|win32|win64/i);
6712570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6713570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($MAIN_CPP_DIR and $AbsPath=~/\A\Q$MAIN_CPP_DIR\E/ and not $STDCXX_TESTING)
6714570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # skip /usr/include/c++/*/ headers
6715570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return () if(not $ExtraInfo);
6716570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6717570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurInclude, $AbsPath);
6719570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep { $AbsDir eq $_ } @DefaultGccPaths
672074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    or (grep { $AbsDir eq $_ } @DefaultIncPaths and fromLibc($AbsPath)))
6721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check "real" (non-"model") include paths
6722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = detect_real_includes($AbsPath, $LibVersion);
6723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        pop(@RecurInclude);
6724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @Paths;
6725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Header_Includes{$LibVersion}{$AbsPath}})) {
6727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_header_includes($AbsPath, $LibVersion);
6728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Include (keys(%{$Header_Includes{$LibVersion}{$AbsPath}}))
6730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $IncType = $Header_Includes{$LibVersion}{$AbsPath}{$Include};
6732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HPath = "";
6733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType<0)
6734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for #include "..."
673574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P($AbsDir, $Include);
6736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
673774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $HPath = realpath($Candidate);
6738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6740850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($IncType>0
67411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Include=~/[\/\\]/) # and not find_in_defaults($Include)
6742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for the nearest header
6743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # QtCore/qabstractanimation.h includes <QtCore/qobject.h>
674474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P(get_dirname($AbsDir), $Include);
6745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
6746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $HPath = $Candidate;
6747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HPath) {
675062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HPath = identifyHeader($Include, $LibVersion);
6751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HPath);
6753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HPath eq $AbsPath) {
6754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
6755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
67569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
67579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Debug)
67589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # boundary headers
675974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             if($HPath=~/vtk/ and $AbsPath!~/vtk/)
676074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             {
676174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#                 print STDERR "$AbsPath -> $HPath\n";
676274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             }
67639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
67649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
6765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RecursiveIncludes{$LibVersion}{$AbsPath}{$HPath} = $IncType;
6766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType>0)
6767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only include <...>, skip include "..." prefixes
6768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Include_Prefix{$LibVersion}{$AbsPath}{$HPath}{get_dirname($Include)} = 1;
6769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $IncPath (detect_recursive_includes($HPath, $LibVersion))
6771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($IncPath eq $AbsPath) {
6773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6775850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $RIncType = $RecursiveIncludes{$LibVersion}{$HPath}{$IncPath};
6776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($RIncType==-1)
6777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # include "..."
6778850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $RIncType = $IncType;
6779850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6780850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($RIncType==2)
6781850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
6782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($IncType!=-1) {
6783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $RIncType = $IncType;
6784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
6785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6786850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$IncPath} = $RIncType;
6787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$HPath}{$IncPath}})) {
6788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Include_Prefix{$LibVersion}{$AbsPath}{$IncPath}{$Prefix} = 1;
6789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dep (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}}))
6792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GlibcHeader{get_filename($Dep)} and keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}})>=2
6794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""})
6795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # distinguish math.h from glibc and math.h from the tested library
6796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""});
6797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                last;
6798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurInclude);
6802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_framework($$$)
6806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Framework, $LibVersion) = @_;
6808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header or not $Framework or not $LibVersion);
6809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header}) {
6810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header};
6811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dependency (sort {get_depth($a)<=>get_depth($b)} keys(%{$Header_Dependency{$LibVersion}}))
6813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_filename($Dependency) eq $Framework
6815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and -f get_dirname($Dependency)."/".$Header) {
6816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = get_dirname($Dependency));
6817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = "");
6820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_defaults($)
6823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Header = $_[0];
6825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header);
6826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_defaults"}{$Header}) {
6827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_defaults"}{$Header};
6828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6829570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultIncPaths,
6830570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultGccPaths,
6831570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultCppPaths,
6832570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @UsersIncPath)
6833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Dir);
6835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Dir."/".$Header) {
6836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_defaults"}{$Header}=$Dir);
6837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_defaults"}{$Header}="");
6840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_paths($$)
6843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path1, $Path2) = @_;
6845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts1 = split(/[\/\\]/, $Path1);
6846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts2 = split(/[\/\\]/, $Path2);
6847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Num (0 .. $#Parts1)
6848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part1 = $Parts1[$Num];
6850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part2 = $Parts2[$Num];
6851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GlibcDir{$Part1}
6852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part2}) {
6853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($GlibcDir{$Part2}
6856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part1}) {
6857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1=~/glib/
6860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2!~/glib/) {
6861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1!~/glib/
6864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2=~/glib/) {
6865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $CmpRes = ($Part1 cmp $Part2)) {
6868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $CmpRes;
6869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkRelevance($)
6875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
68768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
6877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Path);
68788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot) {
6880a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Path = cut_path_prefix($Path, $SystemRoot);
6881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
68828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
68838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = lc(get_filename($Path));
68848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = lc(get_dirname($Path));
68858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6886a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $Name=~s/\.\w+\Z//g; # remove extension (.h)
68878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
68888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Token (split(/[_\d\W]+/, $Name))
6889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
68908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Len = length($Token);
68918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if($Len<=1);
68928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Dir=~/(\A|lib|[_\d\W])\Q$Token\E([_\d\W]|lib|\Z)/)
68938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # include/evolution-data-server-1.4/libebook/e-book.h
68948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
68958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
68968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Len>=4 and index($Dir, $Token)!=-1)
6897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # include/gupnp-1.0/libgupnp/gupnp-context.h
6898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkFamily(@)
6905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Paths = @_;
6907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#Paths<=0);
6908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefix = ();
6909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (@Paths)
6910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
6912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = cut_path_prefix($Path, $SystemRoot);
6913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($Path))
6915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Dir=~s/(\/[^\/]+?)[\d\.\-\_]+\Z/$1/g; # remove version suffix
6917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{$Dir} += 1;
6918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{get_dirname($Dir)} += 1;
6919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort keys(%Prefix))
6922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_depth($_)>=3
6924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Prefix{$_}==$#Paths+1) {
6925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAcceptable($$$)
6932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_dirname($Header))
6936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # with prefix
6937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HName=~/config|setup/i and $Candidate=~/[\/\\]lib\d*[\/\\]/)
6940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for glibconfig.h in /usr/lib/glib-2.0/include/
6941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkRelevance($Candidate))
6944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for atk.h in /usr/include/atk-1.0/atk/
6945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkFamily(getSystemHeaders($HName, $LibVersion)))
6948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # /usr/include/qt4/QtNetwork/qsslconfiguration.h
6949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # /usr/include/qt4/Qt/qsslconfiguration.h
6950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]stdapis[\/\\]/) {
6955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRelevant($$$)
6962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # disallow to search for "abstract" headers in too deep directories
6963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\](tools|stlportv5)[\/\\]/) {
6968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "bsd")
69729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
6973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]include[\/\\]bsd[\/\\]/)
6974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # openssh: skip /usr/lib/bcc/include/bsd/signal.h
6975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "windows")
69799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
69809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Candidate=~/[\/\\](wine|msvcrt|windows)[\/\\]/)
69819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # skip /usr/include/wine/msvcrt
69829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return 0;
69839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
69849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
6985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
6986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate=~/[\/\\]wx[\/\\]/)
6987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # do NOT search in system /wx/ directory
6988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for headers without a prefix: sstream.h
6989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/c\+\+[\/\\]\d+/ and $MAIN_CPP_DIR
6992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\A\Q$MAIN_CPP_DIR\E/)
6993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip ../c++/3.3.3/ if using ../c++/4.5/
6994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/[\/\\]asm-/
6997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and (my $Arch = getArch($LibVersion)) ne "unknown")
6998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # arch-specific header files
6999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate!~/[\/\\]asm-\Q$Arch\E/)
7000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {# skip ../asm-arm/ if using x86 architecture
7001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = getSystemHeaders($HName, $LibVersion);
7005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#Candidates==1)
7006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique header
7007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SCandidates = getSystemHeaders($Header, $LibVersion);
7010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#SCandidates==1)
7011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique name
7012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SystemDepth = $SystemRoot?get_depth($SystemRoot):0;
7015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_depth($Candidate)-$SystemDepth>=5)
7016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # abstract headers in too deep directories
7017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # sstream.h or typeinfo.h in /usr/include/wx-2.9/wx/
7018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isAcceptable($Header, $Candidate, $LibVersion)) {
7019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header eq "parser.h"
7023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\/libxml2\//)
7024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # select parser.h from xml2 library
7025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$SystemHeaders{$HName}})>=3)
7029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # many headers with the same name
7030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # like thread.h included without a prefix
7031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not checkFamily(@Candidates)) {
7032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
7036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub selectSystemHeader($$)
703962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
704062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"selectSystemHeader"}{$_[1]}{$_[0]}) {
704162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"selectSystemHeader"}{$_[1]}{$_[0]};
704262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
704362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"selectSystemHeader"}{$_[1]}{$_[0]} = selectSystemHeader_I(@_));
704462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
704562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
704662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectSystemHeader_I($$)
7047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
704962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(-f $Header) {
705062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header;
705162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
705262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
705362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
705462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
705562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $ConfHeaders{lc($Header)})
705762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # too abstract configuration headers
705862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
705962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $HName = get_filename($Header);
7061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
7062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
70639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $WinHeaders{lc($HName)}
70649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        or $HName=~/windows|win32|win64/i)
706562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # windows headers
7066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
70689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
70699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup ne "macos")
70709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
70719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($HName eq "fp.h")
707274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # pngconf.h includes fp.h in Mac OS
7073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
707674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
707774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(defined $ObsoleteHeaders{$HName})
707874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # obsolete headers
707974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return "";
7080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
708174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "linux" or $OSgroup eq "bsd")
708207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
708374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $AlienHeaders{$HName}
708474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or defined $AlienHeaders{$Header})
708574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # alien headers from other systems
708607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            return "";
708707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
708807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
708962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7090570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"include"}})
7091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in default paths
7092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Header) {
709374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path,$Header);
7094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7096e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"})
709762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # register all headers in system include dirs
7098e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
7099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort {get_depth($a)<=>get_depth($b)}
7101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort {cmp_paths($b, $a)} getSystemHeaders($Header, $LibVersion))
7102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isRelevant($Header, $Candidate, $LibVersion)) {
710462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Candidate;
7105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
710762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # error
710862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSystemHeaders($$)
7112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = ();
7115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort keys(%{$SystemHeaders{$Header}}))
7116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
711762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(skipHeader($Candidate, $LibVersion)) {
7118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
7119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Candidates, $Candidate);
7121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Candidates;
7123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_path_prefix($$)
7126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Prefix) = @_;
7128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path if(not $Prefix);
7129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Prefix=~s/[\/\\]+\Z//;
7130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path=~s/\A\Q$Prefix\E([\/\\]+|\Z)//;
7131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_default_include_dir($)
7135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
7137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//;
7138570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return grep { $Dir eq $_ } (@DefaultGccPaths, @DefaultCppPaths, @DefaultIncPaths);
7139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
714162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader($$)
714262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
7143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
714462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
714562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
7146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
714762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Header=~s/\A(\.\.[\\\/])+//g;
714862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"identifyHeader"}{$LibVersion}{$Header}) {
714962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"identifyHeader"}{$LibVersion}{$Header};
7150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
715162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"identifyHeader"}{$LibVersion}{$Header} = identifyHeader_I($Header, $LibVersion));
7152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
715462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader_I($$)
7155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search for header by absolute path, relative path or name
7156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header)
7158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # it's relative or absolute path
7159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return get_abs_path($Header);
7160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($GlibcHeader{$Header} and not $GLIBC_TESTING
7162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $HeaderDir = find_in_defaults($Header))
7163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for libc headers in the /usr/include
7164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for non-libc target library before searching
7165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # in the library paths
716674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($HeaderDir,$Header);
7167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $Path = $Include_Neighbors{$LibVersion}{$Header})
7169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the target library paths
7170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Path;
7171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7172570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultGccHeader{$Header})
7173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the internal GCC include paths
7174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultGccHeader{$Header};
7175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7176dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(my $DefaultDir = find_in_defaults($Header))
7177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default GCC include paths
717874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($DefaultDir,$Header);
7179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7180570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultCppHeader{$Header})
7181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default G++ include paths
7182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultCppHeader{$Header};
7183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $AnyPath = selectSystemHeader($Header, $LibVersion))
7185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search everywhere in the system
7186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $AnyPath;
7187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
718862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($OSgroup eq "macos")
718962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # search in frameworks: "OpenGL/gl.h" is "OpenGL.framework/Headers/gl.h"
719062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Dir = get_dirname($Header))
719162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
719262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $RelPath = "Headers\/".get_filename($Header);
719362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HeaderDir = find_in_framework($RelPath, $Dir.".framework", $LibVersion)) {
719474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HeaderDir, $RelPath);
719562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
719662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
7197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
719862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # cannot find anything
719962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLocation($)
7203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7204dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7205dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7206dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/srcp[ ]*:[ ]*([\w\-\<\>\.\+\/\\]+):(\d+) /) {
72079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return (path_format($1, $OSgroup), $2);
7208dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
72100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ();
7211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameByInfo($)
7214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7215989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7216dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7217dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /)
7218dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
7219dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $NInfo = $LibInfo{$Version}{"info"}{$1})
7220dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
7221dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($NInfo=~/strg[ ]*:[ ]*(.*?)[ ]+lngt/)
7222dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # short unsigned int (may include spaces)
72238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Str = $1;
72248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($CppMode{$Version}
72258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $Str=~/\Ac99_(.+)\Z/)
72268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
72278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($CppKeywords_A{$1}) {
72288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            $Str=$1;
72298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
72308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
72318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return $Str;
7232dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
7233dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
7234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
7237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeStr($)
7240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7241989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7243989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/strg[ ]*:[ ]*([^ ]*)/)
7244989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7245989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Str = $1;
724607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}
7247570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $Str=~/\Ac99_(.+)\Z/)
7248570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
7249989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CppKeywords_A{$1}) {
7250989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $Str=$1;
7251989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7253989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $Str;
7254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7256989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncShortName($)
7260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7261989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7263570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(index($Info, " operator ")!=-1)
7264989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7265570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Info, " conversion ")!=-1)
726662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
726762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Rid = $SymbolInfo{$Version}{$_[0]}{"Return"})
726862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
726962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $RName = $TypeInfo{$Version}{$Rid}{"Name"}) {
727062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator ".$RName;
727162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
727262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
7273989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7274989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
7275989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
727662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Info=~/ operator[ ]+([a-zA-Z]+) /)
727762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
727862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $Ind = $Operator_Indication{$1}) {
727962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator".$Ind;
728062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
728162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    elsif(not $UnknownOperator{$1})
728262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
728362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        printMsg("WARNING", "unknown operator $1");
728462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $UnknownOperator{$1} = 1;
728562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
7286989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7287989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+) /) {
7292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return getTreeStr($1);
7293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7296989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncReturn($)
7300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7301989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7302989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7303989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7304989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7305989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/retn[ ]*:[ ]*@(\d+) /) {
7306989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return $1;
7307989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncOrig($)
7314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7315989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7316989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7317989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/orig[ ]*:[ ]*@(\d+) /) {
7318989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7319989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7321989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return $_[0];
7322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangleArray(@)
7325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7326dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0]=~/\A\?/)
7327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC mangling
7328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UndNameCmd = get_CmdPath("undname");
7329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UndNameCmd) {
7330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"undname\"");
7331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        writeFile("$TMP_DIR/unmangle", join("\n", @_));
7333a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return split(/\n/, `$UndNameCmd 0x8386 \"$TMP_DIR/unmangle\"`);
7334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC mangling
7337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CppFiltCmd = get_CmdPath("c++filt");
7338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CppFiltCmd) {
7339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find c++filt in PATH");
7340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
73419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not defined $CPPFILT_SUPPORT_FILE)
73429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
73439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $Info = `$CppFiltCmd -h 2>&1`;
73449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $CPPFILT_SUPPORT_FILE = $Info=~/\@<file>/;
73459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
7346570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $NoStrip = ($OSgroup=~/macos|windows/)?"-n":"";
73479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CPPFILT_SUPPORT_FILE)
73489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # new versions of c++filt can take a file
73499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_CPPFILT_FILE_SIZE)
73509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # c++filt <= 2.22 may crash on large files (larger than 8mb)
73519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # this is fixed in the oncoming version of Binutils
73529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
73539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
73549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
73559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            else
73569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
73579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                writeFile("$TMP_DIR/unmangle", join("\n", @_));
73589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip \@\"$TMP_DIR/unmangle\"`;
73599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_CPPFILT_FILE_SIZE constant");
73629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old-style unmangling
73689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_COMMAND_LINE_ARGUMENTS)
73699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
7370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
7371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
7372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
7374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Strings = join(" ", @_);
73769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip $Strings`;
73779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_COMMAND_LINE_ARGUMENTS constant");
73809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_ChargeLevel($$)
7388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
738962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
739062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if($Symbol!~/\A(_Z|\?)/);
739162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
739262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
7393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
739462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"})
7395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7396f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/C1[EI]/) {
7397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7399f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/C2[EI]/) {
7400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
740362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"})
7404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7405f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/D1[EI]/) {
7406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7408f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D2[EI]/) {
7409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7411f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D0[EI]/) {
7412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge-deleting]";
7413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7418f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Symbol=~/C1[EI]/) {
7419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7421f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/C2[EI]/) {
7422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7424f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D1[EI]/) {
7425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7427f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D2[EI]/) {
7428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7430f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D0[EI]/) {
7431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge-deleting]";
7432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub get_Signature_M($$)
74380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
74390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
74400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Signature_M = $tr_name{$Symbol};
74410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $RTid = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
74420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # add return type name
744362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Signature_M = $TypeInfo{$LibVersion}{$RTid}{"Name"}." ".$Signature_M;
74440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
74450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Signature_M;
74460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
74470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
7448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Signature($$)
7449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
745062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
745162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_Signature"}{$LibVersion}{$Symbol}) {
745262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_Signature"}{$LibVersion}{$Symbol};
7453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
745462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
74558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Signature, @Param_Types_FromUnmangledName) = ();
7456ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
745762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
74588a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
745962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
7462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
7463aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
7464aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            $ClassName=~s/\bstruct //g;
74658a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
74668a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(index($Symbol, "_ZTV")==0) {
74678a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                return "vtable for $ClassName [data]";
74688a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
74698a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
7470aef5cd15835e4fc9867e35f89edba6e3211eb7bfAndrey Ponomarenko            $Signature .= $ClassName."::";
7471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}) {
7472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Signature .= "~";
7473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
7474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
747662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"}) {
7477fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $NameSpace."::".$ShortName;
7478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
748207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my ($Short, $Params) = split_Signature($tr_name{$MnglName});
748307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @Param_Types_FromUnmangledName = separate_Params($Params, 0, 1);
7484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
7486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
7487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Signature .= $MnglName;
7488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @ParamArray = ();
749062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
7491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
74928a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($Pos eq "") {
74938a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            next;
74948a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
74958a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
749662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"};
74978a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if(not $ParamTypeId) {
74988a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            next;
74998a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
75008a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
750162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeName = $TypeInfo{$LibVersion}{$ParamTypeId}{"Name"};
7502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ParamTypeName) {
7503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamTypeName = $Param_Types_FromUnmangledName[$Pos];
7504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
7506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
75078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
75088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $ParamTypeName=~s/\b\Q$Typedef\E\b/$Base/g;
75098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
7510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ParamName = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"name"})
7512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
7513f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($ParamName eq "this"
7514f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $Symbol=~/\A(_Z|\?)/)
7515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # do NOT show first hidded "this"-parameter
7516f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
7517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
7518f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            push(@ParamArray, create_member_decl($ParamTypeName, $ParamName));
7519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ParamArray, $ParamTypeName);
7522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
752462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"}
752562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or $GlobalDataObject{$LibVersion}{$Symbol}) {
75268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " [data]";
7527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
753062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add [in-charge]
75328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " ".$ChargeLevel;
7533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
75348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " (".join(", ", @ParamArray).")";
753562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Const"}
753662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(V|)K/) {
75378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " const";
7538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
753962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Volatile"}
754062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(K|)V/) {
75418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " volatile";
7542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
754362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Static"}
754462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Symbol=~/\A(_Z|\?)/)
754574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # for static methods
75468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " [static]";
7547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $ShowRetVal
755062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and my $ReturnTId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"}) {
75518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= ":".$TypeInfo{$LibVersion}{$ReturnTId}{"Name"};
7552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
75548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
75568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"get_Signature"}{$LibVersion}{$Symbol} = $Signature);
7557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_member_decl($$)
7560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TName, $Member) = @_;
7562989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($TName=~/\([\*]+\)/)
7563989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TName=~s/\(([\*]+)\)/\($1$Member\)/;
7565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName;
7566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ArraySizes = ();
7570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($TName=~s/(\[[^\[\]]*\])\Z//) {
7571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ArraySizes, $1);
7572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName." ".$Member.join("", @ArraySizes);
7574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncType($)
7578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7579989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7580989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7581989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7582989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7583989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $Type = $LibInfo{$Version}{"info_type"}{$1})
7584989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
7585989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Type eq "method_type") {
7586989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Method";
7587989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7588989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($Type eq "function_type") {
7589989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Function";
7590989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7591989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
7592989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Other";
7593989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7594989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7595989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7597f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return "";
7598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncTypeId($)
7601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7602989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7603989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7604989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+)( |\Z)/) {
7605989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7606989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7608989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAnon($)
7612989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # "._N" or "$_N" in older GCC versions
7613989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($_[0] and $_[0]=~/(\.|\$)\_\d+|anon\-/);
7614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
76169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub formatName($$)
761762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # type name correction
76189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
76199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"formatName"}{$_[1]}{$_[0]};
762062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
762162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7622f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $_[0];
762362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] ne "S")
76259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/\A[ ]+//g;
76279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]+\Z//g;
76289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]{2,}/ /g;
76299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
76309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
76319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
763262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
763399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    $N=~s/\b(const|volatile) ([\w\:]+)([\*&,>]|\Z)/$2 $1$3/g; # "const void" to "void const"
763499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
7635f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\bvolatile const\b/const volatile/g;
763662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7637f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
7638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(short|long) int\b/$1/g;
763962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7640f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
764162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7642f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while($N=~s/>>/> >/g) {};
764362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] eq "S")
76459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($N, "operator")!=-1) {
76479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N=~s/\b(operator[ ]*)> >/$1>>/;
76489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
76499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
765062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7651dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko    $N=~s/,([^ ])/, $1/g;
765299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
76539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
7654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_HeaderDeps($$)
7657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
7659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath or not $LibVersion);
7660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}) {
7661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %IncDir = ();
7664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_recursive_includes($AbsPath, $LibVersion);
7665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderPath (keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}}))
7666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HeaderPath);
7668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($MAIN_CPP_DIR and $HeaderPath=~/\A\Q$MAIN_CPP_DIR\E([\/\\]|\Z)/);
7669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Dir = get_dirname($HeaderPath);
7670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$HeaderPath}}))
7671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dep = $Dir;
7673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Prefix)
7674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($OSgroup eq "windows")
7676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # case insensitive seach on windows
7677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//ig) {
7678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
7679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($OSgroup eq "macos")
7682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # seach in frameworks
7683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
7685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($HeaderPath=~/(.+\.framework)\/Headers\/([^\/]+)/)
7686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# frameworks
7687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my ($HFramework, $HName) = ($1, $2);
7688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $Dep = $HFramework;
7689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
7691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# mismatch
7692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
7693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Linux, FreeBSD
7698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
7699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $Dep)
7702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nothing to include
7703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(is_default_include_dir($Dep))
7706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # included by the compiler
7707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_depth($Dep)==1)
7710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too short
7711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isLibcDir($Dep))
7714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # do NOT include /usr/include/{sys,bits}
7715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7717570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $IncDir{$Dep} = 1;
7718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath} = sortIncPaths([keys(%IncDir)], $LibVersion);
7721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub sortIncPaths($$)
7725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $LibVersion) = @_;
7727989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $ArrRef or $#{$ArrRef}<0) {
7728989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $ArrRef;
7729989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {$b cmp $a} @{$ArrRef};
7731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_depth($a)<=>get_depth($b)} @{$ArrRef};
7732989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    @{$ArrRef} = sort {sortDeps($b, $a, $LibVersion)} @{$ArrRef};
7733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ArrRef;
7734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7736989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub sortDeps($$$)
7737989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{
7738989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Header_Dependency{$_[2]}{$_[0]}
7739989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and not $Header_Dependency{$_[2]}{$_[1]}) {
7740989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return 1;
7741989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7742989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    elsif(not $Header_Dependency{$_[2]}{$_[0]}
7743989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and $Header_Dependency{$_[2]}{$_[1]}) {
7744989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return -1;
7745989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7746989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7747989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko}
7748989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
774974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub join_P($$)
775074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
775174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $S = "/";
775274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "windows") {
775374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $S = "\\";
775474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
775574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return join($S, @_);
7756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_namespace_additions($)
7759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $NameSpaces = $_[0];
7761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Additions, $AddNameSpaceId) = ("", 1);
7762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NS (sort {$a=~/_/ <=> $b=~/_/} sort {lc($a) cmp lc($b)} keys(%{$NameSpaces}))
7763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($SkipNameSpaces{$Version}{$NS});
7765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $NS or $NameSpaces->{$NS}==-1);
7766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/(\A|::)iterator(::|\Z)/i);
7767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/\A__/i);
7768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(($NS=~/\Astd::/ or $NS=~/\A(std|tr1|rel_ops|fcntl)\Z/) and not $STDCXX_TESTING);
77691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $NestedNameSpaces{$Version}{$NS} = 1; # for future use in reports
7770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypeDecl_Prefix, $TypeDecl_Suffix) = ();
7771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @NS_Parts = split(/::/, $NS);
7772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($#NS_Parts==-1);
7773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS_Parts[0]=~/\A(random|or)\Z/);
7774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $NS_Part (@NS_Parts)
7775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Prefix .= "namespace $NS_Part\{";
7777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Suffix .= "}";
7778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
777974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TypeDecl = $TypeDecl_Prefix."typedef int tmp_add_type_".$AddNameSpaceId.";".$TypeDecl_Suffix;
7780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FuncDecl = "$NS\:\:tmp_add_type_$AddNameSpaceId tmp_add_func_$AddNameSpaceId(){return 0;};";
7781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Additions.="  $TypeDecl\n  $FuncDecl\n";
7782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $AddNameSpaceId+=1;
7783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Additions;
7785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub path_format($$)
778874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
7789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Fmt) = @_;
779074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $Path=~s/[\/\\]+\.?\Z//g;
77911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Fmt eq "windows")
77921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
7793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\//\\/g;
7794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=lc($Path);
7795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
779674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
779774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # forward slash to pass into MinGW GCC
7798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\//g;
7799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub inc_opt($$)
7804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Style) = @_;
7806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Style eq "GCC")
78071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC options
7808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
78091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # to MinGW GCC
7810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I\"".path_format($Path, "unix")."\"";
7811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($OSgroup eq "macos"
7813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\.framework\Z/)
7814570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # to Apple's GCC
7815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-F".esc(get_dirname($Path));
7816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I".esc($Path);
7819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Style eq "CL") {
782262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "/I \"".$Path."\"";
7823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub platformSpecs($)
7828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
7830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = getArch($LibVersion);
7831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # options for GCCE compiler
7833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Symbian_Opts = map {$_=>1} (
7834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__GCCE__",
7835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DUNICODE",
7836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-fexceptions",
7837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SYMBIAN32__",
7838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_INTERWORK__",
7839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_UNICODE",
7840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_50__",
7841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_3X__",
7842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SERIES60_3X__",
7843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EPOC32__",
7844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM__",
7845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EABI__",
7846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_ARMV5__",
7847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SUPPORT_CPP_EXCEPTIONS__",
7848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-march=armv5t",
7849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mapcs",
7850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mthumb-interwork",
7851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DEKA2",
7852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSYMBIAN_ENABLE_SPLIT_HEADERS"
7853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        );
7854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%Symbian_Opts));
7855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows"
7857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i)
7858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add options to MinGW compiler
7859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to simulate the MSVC compiler
7860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MinGW_Opts = map {$_=>1} (
7861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_WIN32",
7862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_STDCALL_SUPPORTED",
7863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int64=\"long long\"",
7864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int32=int",
7865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int16=short",
7866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int8=char",
7867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__possibly_notnullterminated=\" \"",
7868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullterminated=\" \"",
7869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullnullterminated=\" \"",
7870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__w64=\" \"",
7871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr32=\" \"",
7872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr64=\" \"",
7873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=inline",
7874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__inline=inline",
7875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__uuidof(x)=IID()",
7876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__try=",
7877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__except(x)=",
7878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__declspec(x)=__attribute__((x))",
7879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__pragma(x)=",
7880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_inline=inline",
7881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=__inline",
7882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__stdcall=__attribute__((__stdcall__))",
7883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__cdecl=__attribute__((__cdecl__))",
7884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__fastcall=__attribute__((__fastcall__))",
7885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__thiscall=__attribute__((__thiscall__))",
7886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_stdcall=__attribute__((__stdcall__))",
7887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_cdecl=__attribute__((__cdecl__))",
7888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_fastcall=__attribute__((__fastcall__))",
7889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_thiscall=__attribute__((__thiscall__))",
7890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSHSTDAPI_(x)=x",
7891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_EXTENSIONS",
7892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSECURITY_WIN32",
7893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_VER=1500",
7894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_USE_DECLSPECS_FOR_SAL",
7895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__noop=\" \"",
7896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DDECLSPEC_DEPRECATED=\" \"",
7897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__builtin_alignof(x)=__alignof__(x)",
7898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSORTPP_PASS");
7899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch eq "x86") {
7900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IX86=300"}=1;
7901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "x86_64") {
7903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_AMD64=300"}=1;
7904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "ia64") {
7906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IA64=300"}=1;
7907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%MinGW_Opts));
7909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %C_Structure = map {$_=>1} (
7914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# FIXME: Can't separate union and struct data types before dumping,
7915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# so it sometimes cause compilation errors for unknown reason
7916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# when trying to declare TYPE* tmp_add_class_N
7917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This is a list of such structures + list of other C structures
7918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigval",
7919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigevent",
7920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaction",
7921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigvec",
7922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigstack",
7923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeval",
7924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timezone",
7925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rusage",
7926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rlimit",
7927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wait",
7928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "flock",
7929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat",
7930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat",
7931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat32",
7932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat32",
7933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat64",
7934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat64",
7935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stati64",
7936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "if_nameindex",
7937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "usb_device",
7938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaltstack",
7939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sysinfo",
7940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeLocale",
7941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tcp_debug",
7942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc_createerr",
794382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Other
7944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timespec",
7945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "random_data",
7946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "drand48_data",
7947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_marker",
7948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_FILE",
7949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lconv",
7950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched_param",
7951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tm",
7952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "itimerspec",
7953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_pthread_cleanup_buffer",
7954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fd_set",
795501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    "siginfo",
795682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "mallinfo",
7957570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "timex",
795874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sigcontext",
795974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ucontext",
796082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Mac
796182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_timex",
796282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_t",
796382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_category_t",
796482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_ro_t",
796582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_protocol_t",
796682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_message_ref_t",
796782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_super_message_ref_t",
796882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_t",
796982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_list_t"
7970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
7971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getCompileCmd($$$)
7973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Opt, $Inc) = @_;
7975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccCall = $GCC_PATH;
7976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Opt) {
7977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opt;
7978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $GccCall .= " -x ";
7980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos") {
7981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "objective-";
7982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7983f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
7984f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($EMERGENCY_MODE_48)
7985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # workaround for GCC 4.8 (C only)
7986f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $GccCall .= "c++";
7987f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
7988f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    elsif(check_gcc($GCC_PATH, "4"))
7989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" header
7990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to obtain complete dump using GCC 4.0
7991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++-header";
7992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" source
7995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # GCC 3.3 cannot compile headers
7996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++";
7997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Opts = platformSpecs($Version))
7999d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # platform-specific options
8000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opts;
8001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # allow extra qualifications
8003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # and other nonconformant code
800401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -fpermissive";
800501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -w";
8006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($NoStdInc)
8007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc";
8009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc++";
8010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8011d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(my $Opts_GCC = getGCC_Opts($Version))
8012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined options
8013d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $GccCall .= " ".$Opts_GCC;
8014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8015a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $GccCall .= " \"$Path\"";
8016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Inc)
8017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # include paths
8018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Inc;
8019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccCall;
8021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
802301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub detectPreamble($$)
8024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
802501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Content, $LibVersion) = @_;
8026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeaderElems = (
8027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Types
8028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdio.h" => ["FILE", "va_list"],
8029850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "stddef.h" => ["NULL", "ptrdiff_t"],
80309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdint.h" => ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
80319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                       "int8_t", "int16_t", "int32_t", "int64_t"],
8032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "time.h" => ["time_t"],
8033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "sys/types.h" => ["ssize_t", "u_int32_t", "u_short", "u_char",
80349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                          "u_int", "off_t", "u_quad_t", "u_long", "mode_t"],
80359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "unistd.h" => ["gid_t", "uid_t", "socklen_t"],
8036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdbool.h" => ["_Bool"],
8037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "rpc/xdr.h" => ["bool_t"],
8038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "in_systm.h" => ["n_long", "n_short"],
8039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Fields
8040bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        "arpa/inet.h" => ["fw_src", "ip_src"],
8041bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        # Functions
80429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdlib.h" => ["free", "malloc", "size_t"],
8043850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "string.h" => ["memmove", "strcmp"]
8044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
8045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AutoPreamble = ();
8046850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (keys(%HeaderElems))
8047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
8048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Elem (@{$HeaderElems{$_}}) {
80499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $AutoPreamble{$Elem} = $_;
8050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
805201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %Types = ();
805301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    while($Content=~s/error\:\s*(field\s*|)\W+(.+?)\W+//)
805401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # error: 'FILE' has not been declared
80559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Types{$2} = 1;
805601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
805701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%Types))
805801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
805901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my %AddHeaders = ();
806001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        foreach my $Type (keys(%Types))
806101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
806201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $Header = $AutoPreamble{$Type})
806301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
80649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Path = identifyHeader($Header, $LibVersion))
80659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
80669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(skipHeader($Path, $LibVersion)) {
80679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
80689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
80699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Path = path_format($Path, $OSgroup);
80709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Type"} = $Type;
80719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Header"} = $Header;
807201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
807301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
807401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
807501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(keys(%AddHeaders)) {
80769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return \%AddHeaders;
807701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
807801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
80799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return undef;
808001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
808101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
8082f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub checkCTags($)
8083f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko{
8084f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Path = $_[0];
8085f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $Path) {
8086f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8087f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8088570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $CTags = undef;
8089570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8090570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($OSgroup eq "bsd")
8091570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # use ectags on BSD
8092570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ectags");
8093570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CTags) {
8094570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            printMsg("WARNING", "can't find \'ectags\' program");
8095570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8096570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8097f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $CTags) {
8098570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ctags");
8099570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8100570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $CTags)
8101570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8102570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("WARNING", "can't find \'ctags\' program");
8103f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8104f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8105bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
810682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if($OSgroup ne "linux")
810782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    { # macos, freebsd, etc.
8108bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Info = `$CTags --version 2>\"$TMP_DIR/null\"`;
8109bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if($Info!~/exuberant/i)
8110bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
8111bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            printMsg("WARNING", "incompatible version of \'ctags\' program");
8112bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            return;
8113bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        }
8114bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    }
8115bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8116f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/ctags.txt";
8117bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    system("$CTags --c-kinds=pxn -f \"$Out\" \"$Path\" 2>\"$TMP_DIR/null\"");
8118f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($Debug) {
81199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        copy($Out, $DEBUG_PATH{$Version}."/ctags.txt");
8120f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8121f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    open(CTAGS, "<", $Out);
8122f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while(my $Line = <CTAGS>)
8123f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
8124f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        chomp($Line);
8125f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($Name, $Header, $Def, $Type, $Scpe) = split(/\t/, $Line);
81269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $Intrinsic_Keywords{$Name})
81279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # noise
81289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
81299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8130f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Type eq "n")
8131f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
81329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "class:")==0) {
81339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
81349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "struct:")==0) {
8136f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                next;
8137f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
81389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "namespace:")==0)
8139f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
81409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Scpe=~s/\Anamespace://) {
81419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Name = $Scpe."::".$Name;
81429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
81439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TUnit_NameSpaces{$Version}{$Name} = 1;
81459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "p")
81479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Funcs{$Version}{$Name} = 1;
81509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "x")
81539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Vars{$Version}{$Name} = 1;
8156f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
8157f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8158f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8159f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    close(CTAGS);
8160f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
8161f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
81628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub preChange($$)
816301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
81648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($HeaderPath, $IncStr) = @_;
81659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
81668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr);
81678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Content = undef;
816807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
8169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows"
8170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i
8171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $MinGWMode{$Version}!=-1)
8172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify headers to compile by MinGW
81738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
81758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/__asm\s*(\{[^{}]*?\}|[^{};]*)//g)
8178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # __asm { ... }
8179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/\s+(\/ \/.*?)\n/\n/g)
8182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # comments after preprocessing
8183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\W)(0x[a-f]+|\d+)(i|ui)(8|16|32|64)(\W)/$1$2$5/g)
8186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 0xffui8
8187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
81908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($MinGWMode{$Version}) {
8191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("INFO", "Using MinGW compatibility mode");
8192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
81948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
8195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($COMMON_LANGUAGE{$Version} eq "C" or $CheckHeadersOnly)
81968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $CppMode{$Version}!=-1 and not $CppCompat and not $CPP_HEADERS)
81971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # rename C++ keywords in C code
8198570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # disable this code by -cpp-compatible option
81998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
82018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_C = join("|", keys(%CppKeywords_C));
8204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_F = join("|", keys(%CppKeywords_F));
8205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_O = join("|", keys(%CppKeywords_O));
8206bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8207bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Detected = undef;
8208bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8209d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        while($Content=~s/(\A|\n[^\#\/\n][^\n]*?|\n)(\*\s*|\s+|\@|\,|\()($RegExp_C|$RegExp_F)(\s*([\,\)\;\.\[]|\-\>|\:\s*\d))/$1$2c99_$3$4/g)
8210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int new, int class, int (*new)(int));
8212d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko          # int foo(char template[], char*);
8213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # unsigned private: 8;
8214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # #pragma GCC visibility push(default)
821607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8217bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
8218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\s]|\w\s+)(?<!operator )(delete)(\s*\()/$1c99_$2$3/g)
8220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int delete(...);
8222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int explicit(...);
8223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void operator delete(...)
822507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8226bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)($RegExp_O)(\s*(\;|\:))/$1c99_$2$3/g)
8229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bool;
8231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # bool X;
8233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # return *this;
8234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # throw;
823507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8236bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)(operator)(\s*(\(\s*\)\s*[^\(\s]|\(\s*[^\)\s]))/$1c99_$2$3/g)
8239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator(...);
8241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator()(...);
824307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8244bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\(\,\s]\s*|\s+)(operator)(\s*(\,\s*[^\(\s]|\)))/$1c99_$2$3/g)
8247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator);
8249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator, int other);
8250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator,(...);
825207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8253bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\*\s*|\w\s+)(bool)(\s*(\,|\)))/$1c99_$2$3/g)
8256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(gboolean *bool);
8258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void setTabEnabled(int index, bool);
826007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8261bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\w)(\s*[^\w\(\,\s]\s*|\s+)(this|throw)(\s*[\,\)])/$1$2c99_$3$4/g)
8264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int* this);
8266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bar(int this);
82679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # int baz(int throw);
8268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
82699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # foo(X, this);
827007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8271bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
827207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
82738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(struct |extern )(template) /$1c99_$2 /g)
82748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # MATCH:
82758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # struct template {...};
82768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # extern template foo(...);
82778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CppMode{$Version} = 1;
82788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Detected = "$1$2" if(not defined $Detected);
82798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
828007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
828107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version} == 1)
828207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
8283bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            if($Debug)
8284bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            {
8285bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                $Detected=~s/\A\s+//g;
8286bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                printMsg("INFO", "Detected code: \"$Detected\"");
828707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
8288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
82909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # remove typedef enum NAME NAME;
82918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @FwdTypedefs = $Content=~/typedef\s+enum\s+(\w+)\s+(\w+);/g;
82929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $N = 0;
82939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while($N<=$#FwdTypedefs-1)
82949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
82959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $S = $FwdTypedefs[$N];
82969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($S eq $FwdTypedefs[$N+1])
82979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
82988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Content=~s/typedef\s+enum\s+\Q$S\E\s+\Q$S\E;//g;
8299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CppMode{$Version} = 1;
8300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Debug) {
8302fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    printMsg("INFO", "Detected code: \"typedef enum $S $S;\"");
8303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
83049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
83059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N+=2;
83069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
83079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
83088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($CppMode{$Version}==1) {
830907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            printMsg("INFO", "Using C++ compatibility mode");
8310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
83128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
831307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1)
83158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $IPath = $TMP_DIR."/dump$Version.i";
83178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($IPath, $Content);
83188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $IPath;
83198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return undef;
83228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
83238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getDump()
83258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
83268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $GCC_PATH) {
83278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        exitStatus("Error", "internal error - GCC path is not set");
83288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my @Headers = keys(%{$Registered_Headers{$Version}});
83318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    @Headers = sort {int($Registered_Headers{$Version}{$a}{"Pos"})<=>int($Registered_Headers{$Version}{$b}{"Pos"})} @Headers;
83328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $IncludeString = getIncString(getIncPaths(@{$Include_Preamble{$Version}}, @Headers), "GCC");
83348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TmpHeaderPath = $TMP_DIR."/dump".$Version.".h";
83368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HeaderPath = $TmpHeaderPath;
83378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # write tmp-header
83398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    open(TMP_HEADER, ">", $TmpHeaderPath) || die ("can't open file \'$TmpHeaderPath\': $!\n");
83408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $AddDefines = $Descriptor{$Version}{"Defines"})
83418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $AddDefines=~s/\n\s+/\n  /g;
83438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "\n  // add defines\n  ".$AddDefines."\n";
83448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    print TMP_HEADER "\n  // add includes\n";
83468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@{$Include_Preamble{$Version}}) {
83478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@Headers)
83508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not grep {$HPath eq $_} (@{$Include_Preamble{$Version}})) {
83528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    close(TMP_HEADER);
83568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($IncludeString) {
83608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-string", $IncludeString);
83618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/recursive-includes", Dumper($RecursiveIncludes{$Version}));
83638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/direct-includes", Dumper($Header_Includes{$Version}));
83648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my @Redirects = keys(%{$Header_ErrorRedirect{$Version}}))
83668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
83678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $REDIR = "";
83688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $P1 (sort @Redirects) {
83698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $REDIR .= $P1.";".$Header_ErrorRedirect{$Version}{$P1}."\n";
83708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
83718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-redirect", $REDIR);
83728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$TargetHeaders{$Version}}))
83768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Target headers
83778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        addTargetHeaders($Version);
8378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8379850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
83818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %RecursiveIncludes = ();
83828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Include_Prefix = ();
83838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Includes = ();
83848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean cache
83868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"identifyHeader"});
83878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"detect_header_includes"});
83888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"selectSystemHeader"});
83898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # preprocessing stage
83918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Pre = callPreprocessor($TmpHeaderPath, $IncludeString, $Version);
83928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    checkPreprocessedUnit($Pre);
83938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/header-paths", join("\n", sort keys(%{$PreprocessedHeaders{$Version}})));
83978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean memory
84008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Include_Neighbors{$Version});
84018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($PreprocessedHeaders{$Version});
84028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++") {
84048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        checkCTags($Pre);
84058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $PrePath = preChange($TmpHeaderPath, $IncludeString))
84088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # try to correct the preprocessor output
84098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $HeaderPath = $PrePath;
84108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
8411850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
8413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add classes and namespaces to the dump
8414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CHdump = "-fdump-class-hierarchy -c";
841507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version}==1
8416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $MinGWMode{$Version}==1) {
8417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHdump .= " -fpreprocessed";
8418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $ClassHierarchyCmd = getCompileCmd($HeaderPath, $CHdump, $IncludeString);
8420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($TMP_DIR);
842162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($ClassHierarchyCmd." >null 2>&1");
8422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ClassDump = (cmd_find($TMP_DIR,"f","*.class",1))[0])
8424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Content = readFile($ClassDump);
8426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $ClassInfo (split(/\n\n/, $Content))
8427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ClassInfo=~/\AClass\s+(.+)\s*/i)
8429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
8430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $CName = $1;
8431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if($CName=~/\A(__|_objc_|_opaque_)/);
8432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TUnit_NameSpaces{$Version}{$CName} = -1;
8433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/\A[\w:]+\Z/)
8434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # classes
8435f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $TUnit_Classes{$Version}{$CName} = 1;
8436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/(\w[\w:]*)::/)
8438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # namespaces
8439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NS = $1;
8440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not defined $TUnit_NameSpaces{$Version}{$NS}) {
8441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TUnit_NameSpaces{$Version}{$NS} = 1;
8442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
8443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($ClassInfo=~/\AVtable\s+for\s+(.+)\n((.|\n)+)\Z/i)
8446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # read v-tables (advanced approach)
8447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($CName, $VTable) = ($1, $2);
8448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ClassVTable_Content{$Version}{$CName} = $VTable;
8449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8451a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $NS (keys(%{$AddNameSpaces{$Version}}))
8452a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            { # add user-defined namespaces
8453a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $TUnit_NameSpaces{$Version}{$NS} = 1;
8454a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
8455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Debug)
8456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # debug mode
8457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                mkpath($DEBUG_PATH{$Version});
84581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                copy($ClassDump, $DEBUG_PATH{$Version}."/class-hierarchy-dump.txt");
8459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($ClassDump);
8461f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8462f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
8463f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # add namespaces and classes
8464f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $NS_Add = get_namespace_additions($TUnit_NameSpaces{$Version}))
8465f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # GCC on all supported platforms does not include namespaces to the dump by default
84668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add namespaces\n".$NS_Add);
8467f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8468f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # some GCC versions don't include class methods to the TU dump by default
8469f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($AddClass, $ClassNum) = ("", 0);
8470570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $GCC_44 = check_gcc($GCC_PATH, "4.4"); # support for old GCC versions
8471f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        foreach my $CName (sort keys(%{$TUnit_Classes{$Version}}))
8472f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
8473f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($C_Structure{$CName});
8474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if(not $STDCXX_TESTING and $CName=~/\Astd::/);
8475f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($SkipTypes{$Version}{$CName});
8476570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $Force and $GCC_44
8477570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $OSgroup eq "linux")
8478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # optimization for linux with GCC >= 4.4
8479570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko              # disable this code by -force option
8480570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(index($CName, "::")!=-1)
8481570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # should be added by name space
848282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
848382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
848482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            }
848582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            else
848682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            {
848782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                if($CName=~/\A(.+)::[^:]+\Z/
848882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                and $TUnit_Classes{$Version}{$1})
848982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                { # classes inside other classes
849082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
849182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
8492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
84939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Funcs{$Version}{$CName})
84949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a function and type
84959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
84969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
84979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Vars{$Version}{$CName})
84989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a variable and type
84999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
85009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
8501f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $AddClass .= "  $CName* tmp_add_class_".($ClassNum++).";\n";
8502f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8503f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($AddClass) {
85048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add classes\n".$AddClass);
8505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "Temporary header file \'$TmpHeaderPath\' with the following content will be compiled to create GCC translation unit dump:\n".readFile($TmpHeaderPath)."\n");
8508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create TU dump
8509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TUdump = "-fdump-translation-unit -fkeep-inline-functions -c";
8510d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($UserLang eq "C") {
8511d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TUdump .= " -U__cplusplus -D_Bool=\"bool\"";
8512d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
851307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1) {
8515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TUdump .= " -fpreprocessed";
8516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
85178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $SyntaxTreeCmd = getCompileCmd($HeaderPath, $TUdump, $IncludeString);
8518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "The GCC parameters:\n  $SyntaxTreeCmd\n\n");
8519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($TMP_DIR);
8520a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($SyntaxTreeCmd." >\"$TMP_DIR/tu_errors\" 2>&1");
8521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Errors = "";
8522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($?)
8523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # failed to compile, but the TU dump still can be created
8524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors = readFile($TMP_DIR."/tu_errors"))
852501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to recompile
852601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko          # FIXME: handle other errors and try to recompile
852707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}==1
85282b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and index($Errors, "c99_")!=-1
85292b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and not defined $CppIncompat)
853001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable c99 mode and try again
853107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $CppMode{$Version}=-1;
85322b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
85332b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                if($Debug)
85342b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                {
85352b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                    # printMsg("INFO", $Errors);
85362b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                }
85372b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
853807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                printMsg("INFO", "Disabling C++ compatibility mode");
853901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
854001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
854101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
8542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
854301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($AutoPreambleMode{$Version}!=-1
85449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            and my $AddHeaders = detectPreamble($Errors, $Version))
854501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # add auto preamble headers and try again
854601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $AutoPreambleMode{$Version}=-1;
85479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Headers = sort {$b cmp $a} keys(%{$AddHeaders}); # sys/types.h should be the first
8548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Num (0 .. $#Headers)
8549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
855001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Path = $Headers[$Num];
8551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Path eq $_} (@{$Include_Preamble{$Version}}))
8552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
8553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        push_U($Include_Preamble{$Version}, $Path);
8554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        printMsg("INFO", "Add \'".$AddHeaders->{$Path}{"Header"}."\' preamble header for \'".$AddHeaders->{$Path}{"Type"}."\'");
8555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                resetLogging($Version);
8558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
8559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return getDump();
8560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
856101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($Cpp0xMode{$Version}!=-1
856201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and ($Errors=~/\Q-std=c++0x\E/
856301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or $Errors=~/is not a class or namespace/))
856401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # c++0x: enum class
8565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(check_gcc($GCC_PATH, "4.6"))
8566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Cpp0xMode{$Version}=-1;
8568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("INFO", "Enabling c++0x mode");
8569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    resetLogging($Version);
8570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $TMP_DIR = tempdir(CLEANUP=>1);
8571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $CompilerOptions{$Version} .= " -std=c++0x";
8572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    return getDump();
8573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else {
8575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("WARNING", "Probably c++0x construction detected");
8576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
857801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
857901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($MinGWMode{$Version}==1)
858001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable MinGW mode and try again
858101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $MinGWMode{$Version}=-1;
858201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
858301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
858401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
858501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
858601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, $Errors);
8587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
858801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        else {
858901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, "$!: $?\n");
8590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "some errors occurred when compiling headers");
8592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printErrorLog($Version);
8593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMPILE_ERRORS = $ERROR_CODE{"Compile_Error"};
8594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeLog($Version, "\n"); # new line
8595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($ORIG_DIR);
8597f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    unlink($TmpHeaderPath);
85988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    unlink($HeaderPath);
8599570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8600570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my @TUs = cmd_find($TMP_DIR,"f","*.tu",1)) {
8601570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $TUs[0];
8602570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8603570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    else
8604570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8605570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $Msg = "can't compile header(s)";
8606570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors=~/error trying to exec \W+cc1plus\W+/) {
8607570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Msg .= "\nDid you install G++?";
8608570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8609570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Cannot_Compile", $Msg);
8610570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmd_file($)
8614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $CmdPath = get_CmdPath("file")) {
8618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return `$CmdPath -b \"$Path\"`;
8619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncString($$)
8624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $Style) = @_;
8626989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "" if(not $ArrRef or $#{$ArrRef}<0);
8627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $String = "";
8628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@{$ArrRef}) {
8629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $String .= " ".inc_opt($_, $Style);
8630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $String;
8632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncPaths(@)
8635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @HeaderPaths = @_;
8637570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my @IncPaths = @{$Add_Include_Paths{$Version}};
8638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($INC_PATH_AUTODETECT{$Version})
8639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # auto-detecting dependencies
8640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Includes = ();
8641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $HPath (@HeaderPaths)
8642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Dir (get_HeaderDeps($HPath, $Version))
8644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip_Include_Paths{$Version}{$Dir}) {
8646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
8647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8648a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if($SystemRoot)
8649a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
8650a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    if($Skip_Include_Paths{$Version}{$SystemRoot.$Dir}) {
8651a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                        next;
8652a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
8653a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
8654570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Includes{$Dir} = 1;
8655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dir (@{sortIncPaths([keys(%Includes)], $Version)}) {
8658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@IncPaths, $Dir);
8659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined paths
8663570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @IncPaths = @{$Include_Paths{$Version}};
8664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \@IncPaths;
8666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8668570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub push_U($@)
8669570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{ # push unique
8670570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $Array = shift @_)
8671570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8672570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(@_)
8673570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
8674570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Exist = map {$_=>1} @{$Array};
8675570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Elem (@_)
8676570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
8677570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not defined $Exist{$Elem})
8678570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8679570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push(@{$Array}, $Elem);
8680570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Exist{$Elem} = 1;
8681570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8682570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
8683570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8684570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8685570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
8686570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub callPreprocessor($$$)
8688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Inc, $LibVersion) = @_;
8690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
8691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $IncludeString=$Inc;
8692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Inc) {
8693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IncludeString = getIncString(getIncPaths($Path), "GCC");
8694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = getCompileCmd($Path, "-dD -E", $IncludeString);
8696f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/preprocessed.h";
8697a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($Cmd." >\"$Out\" 2>\"$TMP_DIR/null\"");
8698dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $Out;
8699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
87014b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub cmd_find($;$$$$)
8702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # native "find" is much faster than File::Find (~6x)
8703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # also the File::Find doesn't support --maxdepth N option
8704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # so using the cross-platform wrapper for the native one
8705570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Path, $Type, $Name, $MaxDepth, $UseRegex) = @_;
8706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -e $Path);
8707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
87116fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Cmd = "dir \"$Path\" /B /O";
8712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth!=1) {
8713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /S";
8714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /AD";
8717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
871874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        elsif($Type eq "f") {
871974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Cmd .= " /A-D";
872074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
8721570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, `$Cmd 2>\"$TMP_DIR/null\"`);
8722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Name)
87238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
87248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $UseRegex)
87258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # FIXME: how to search file names in MS shell?
87268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko              # wildcard to regexp
8727570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Name=~s/\*/.*/g;
87288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Name='\A'.$Name.'\Z';
8729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
87308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/i } @Files;
8731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @AbsPaths = ();
8733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $File (@Files)
8734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not is_abs($File)) {
873674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $File = join_P($Path, $File);
8737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type eq "f" and not -f $File)
8739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # skip dirs
8740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
8741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, path_format($File, $OSgroup));
8743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, $Path);
8746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @AbsPaths;
8748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FindCmd = get_CmdPath("find");
8752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $FindCmd) {
8753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find a \"find\" command");
8754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path and -l $Path
8757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path!~/\/\Z/)
8758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for directories that are symlinks
8759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path.="/";
8760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $FindCmd." \"$Path\"";
8762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth) {
8763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -maxdepth $MaxDepth";
8764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type) {
8766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -type $Type";
8767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8768570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and not $UseRegex)
8769570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # wildcards
8770570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cmd .= " -name \"$Name\"";
8771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
87729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Res = `$Cmd 2>\"$TMP_DIR/null\"`;
87738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($? and $!) {
87749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            printMsg("ERROR", "problem with \'find\' utility ($?): $!");
87759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8776570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, $Res);
8777570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and $UseRegex)
8778570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # regex
87798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/ } @Files;
8780570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
87814b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return @Files;
8782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unpackDump($)
8786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = get_abs_path($Path);
8790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = path_format($Path, $OSgroup);
8791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $FileName) = separate_path($Path);
8792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UnpackDir = $TMP_DIR."/unpack";
8793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    rmtree($UnpackDir);
8794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    mkpath($UnpackDir);
8795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($FileName=~s/\Q.zip\E\Z//g)
8796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UnzipCmd = get_CmdPath("unzip");
8798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UnzipCmd) {
8799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"unzip\" command");
8800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($UnpackDir);
880274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        system("$UnzipCmd \"$Path\" >\"$TMP_DIR/null\"");
8803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?) {
880474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
880774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Contents = cmd_find($UnpackDir, "f");
8808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Contents) {
8809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\'");
8810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
881174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return $Contents[0];
8812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    elsif($FileName=~s/\Q.tar.gz\E(\.\w+|)\Z//g)
8814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8815b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko      # *.tar.gz.amd64 (dh & cdbs)
8816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
8817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -xvzf option is not implemented in tar.exe (2003)
8818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # use "gzip.exe -k -d -f" + "tar.exe -xvf" instead
8819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
8824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $GzipCmd) {
8825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\" command");
8826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
8828a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system("$GzipCmd -k -d -f \"$Path\""); # keep input files (-k)
8829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
8830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
883274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvf \"$Dir\\$FileName.tar\" >\"$TMP_DIR/null\"");
8833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
883474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
8837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Dir."/".$FileName.".tar");
883874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
884274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
884574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # Unix, Mac
8846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
885174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvzf \"$Path\" >\"$TMP_DIR/null\"");
8852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
885374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
885674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
886074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createArchive($$)
8866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $To) = @_;
88685c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $To) {
88695c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $To = ".";
88705c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
8871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path or not -e $Path
8872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -d $To) {
8873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
8874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($From, $Name) = separate_path($Path);
8876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ZipCmd = get_CmdPath("zip");
8879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ZipCmd) {
8880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"zip\"");
8881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = $To."/".$Name.".zip";
8883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($To);
8885a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        system("$ZipCmd -j \"$Name.zip\" \"$Path\" >\"$TMP_DIR/null\"");
8886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "zip")
8888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Pkg;
8894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TarCmd = get_CmdPath("tar");
8898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TarCmd) {
8899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"tar\"");
8900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $GzipCmd = get_CmdPath("gzip");
8902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GzipCmd) {
8903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"gzip\"");
8904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = abs_path($To)."/".$Name.".tar.gz";
8906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($From);
8908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system($TarCmd, "-czf", $Pkg, $Name);
8909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "tar")
8911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $To."/".$Name.".tar.gz";
8917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header_file($)
8921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.($HEADER_EXT)\Z/i) {
8923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $_[0];
8924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_not_header($)
8929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.\w+\Z/
8931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $_[0]!~/\.($HEADER_EXT)\Z/i) {
8932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
8933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header($$$)
8938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $UserDefined, $LibVersion) = @_;
8940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(-d $Header);
8941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header) {
8942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Header = get_abs_path($Header);
8943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Header))
8947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # incorrect absolute path
8948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
895062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HPath = identifyHeader($Header, $LibVersion)) {
8951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header = $HPath;
8952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # can't find header
8955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header=~/\.\w+\Z/)
8959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # have an extension
8960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return is_header_file($Header);
8961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserDefined==2)
8965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified on the command line
8966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(cmd_file($Header)!~/HTML|XML/i) {
8967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($UserDefined)
8971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified in the XML-descriptor
8972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # header file without an extension
8973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Header;
8974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8977570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Header, "/include/")!=-1
8978850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or cmd_file($Header)=~/C[\+]*\s+program/i)
8979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # !~/HTML|XML|shared|dynamic/i
8980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
89871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addTargetHeaders($)
8988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
8990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $RegHeader (keys(%{$Registered_Headers{$LibVersion}}))
8991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegDir = get_dirname($RegHeader);
899346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        $TargetHeaders{$LibVersion}{get_filename($RegHeader)} = 1;
89949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
89959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $INC_PATH_AUTODETECT{$LibVersion}) {
89969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            detect_recursive_includes($RegHeader, $LibVersion);
89979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
89989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
8999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $RecInc (keys(%{$RecursiveIncludes{$LibVersion}{$RegHeader}}))
9000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($RecInc);
9002fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(familiarDirs($RegDir, $Dir)
9004850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $RecursiveIncludes{$LibVersion}{$RegHeader}{$RecInc}!=1)
9005850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # in the same directory or included by #include "..."
900646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($RecInc)} = 1;
9007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9012fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub familiarDirs($$)
9013fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
9014fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($D1, $D2) = @_;
9015fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($D1 eq $D2) {
9016fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
9017fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U1 = index($D1, "/usr/");
9020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U2 = index($D2, "/usr/");
9021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U1==0 and $U2!=0) {
9023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U2==0 and $U1!=0) {
9027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($D2, $D1."/")==0) {
9031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 1;
9032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /usr/include/DIR
9035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /home/user/DIR
9036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $DL = get_depth($D1);
9038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs1 = ($D1);
9040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while($DL - get_depth($D1)<=2
9041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and get_depth($D1)>=4
9042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D1=~s/[\/\\]+[^\/\\]*?\Z//) {
9043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs1, $D1);
9044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs2 = ($D2);
9047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while(get_depth($D2)>=4
9048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D2=~s/[\/\\]+[^\/\\]*?\Z//) {
9049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs2, $D2);
9050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $P1 (@Dirs1)
9053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
9054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $P2 (@Dirs2)
9055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($P1 eq $P2) {
9058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
9059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9060fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9061fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9062fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
9063fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
9064fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readHeaders($)
9066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Version = $_[0];
9068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "checking header(s) ".$Descriptor{$Version}{"Version"}." ...");
9069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DumpPath = getDump();
9070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
9071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug mode
9072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
90731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        copy($DumpPath, $DEBUG_PATH{$Version}."/translation-unit-dump.txt");
9074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getInfo($DumpPath);
9076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub prepareTypes($)
9079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
908162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.0"))
9082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # type names have been corrected in ACC 1.22 (dump 2.0 format)
908462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
9085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
908662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
908762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TName=~/\A(\w+)::(\w+)/) {
908862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($P1, $P2) = ($1, $2);
908962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($P1 eq $P2) {
909062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A$P1:\:$P1(\W)/$P1$1/;
909162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
909262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
909362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A(\w+:\:)$P2:\:$P2(\W)/$1$P2$2/;
9094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
909662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Name"} = $TName;
9097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
909962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.5"))
9100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V < 2.5: array size == "number of elements"
9102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V >= 2.5: array size in bytes
910362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9105f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %Type = get_PureType($TypeId, $TypeInfo{$LibVersion});
910662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Type{"Type"} eq "Array")
9107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
910801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Size = $Type{"Size"})
910962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[N]
9110f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %Base = get_OneStep_BaseType($Type{"Tid"}, $TypeInfo{$LibVersion});
911101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $Size *= $Base{"Size"};
911201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = "$Size";
911362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
911462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
911562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[] is a pointer
911662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $WORD_SIZE{$LibVersion};
9117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V2 = ($LibVersion==1)?2:1;
912262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.7"))
9123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # size of "method ptr" corrected in 2.7
912562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9127f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
912862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($PureType{"Type"} eq "MethodPtr")
9129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
913062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type = get_Type($TypeId, $LibVersion);
913162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TypeId_2 = getTypeIdByName($PureType{"Name"}, $V2);
913262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type2 = get_Type($TypeId_2, $V2);
913362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Type{"Size"} ne $Type2{"Size"}) {
913462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $Type2{"Size"};
9135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
91411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub prepareSymbols($)
9142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
91441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
91451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
91461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # check if input is valid
9147ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
91481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
91491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CheckHeadersOnly) {
91501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty (".$Descriptor{$LibVersion}{"Version"}.")");
91511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            else {
91531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection (".$Descriptor{$LibVersion}{"Version"}.")");
91541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
91561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
91571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Remangle = 0;
915962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.10")
916062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.10"))
9161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
9162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Remangle = 1;
9163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly)
9165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different languages
9166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserLang)
9167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --lang=LANG for both versions
9168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(($UsedDump{1}{"V"} and $UserLang ne $UsedDump{1}{"L"})
9169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or ($UsedDump{2}{"V"} and $UserLang ne $UsedDump{2}{"L"}))
9170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($UserLang eq "C++")
9172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remangle symbols
9173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = 1;
9174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($UserLang eq "C")
9176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remove mangling
9177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = -1;
9178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
918262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
91831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (sort {int($b)<=>int($a)} keys(%{$SymbolInfo{$LibVersion}}))
9184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order: D0, D1, D2, D0 (artificial, GCC < 4.5), C1, C2
918562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.13"))
91860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
91870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
91880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
91890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                foreach my $P (keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}}))
91900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
91910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $TypeId = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"type"};
91920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $DVal = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"};
919362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
91940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $DVal and $DVal ne "")
91950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
91960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($TName eq "char") {
91970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = chr($DVal);
91980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
91990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif($TName eq "bool") {
92000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = $DVal?"true":"false";
92010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
92020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
92030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
92040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
92050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
92061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
9207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
92081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
92091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})
9210082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko            and $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
9211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old GCC < 4.5: skip artificial ~dtor(int __in_chrg)
9212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # + support for old ABI dumps
9213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
9214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
92161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9217850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
92181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassID = $SymbolInfo{$LibVersion}{$InfoId}{"Class"};
9219850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
9220989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
92211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $SRemangle = 0;
922262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.12")
922362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.12"))
92241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # support for old ABI dumps
9225850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($ShortName eq "operator>>")
9226850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9227850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
9228850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of operator>>
9229850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9230850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9232850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
9233850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9234850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
9235850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                and isConstType($Return, $LibVersion) and $MnglName!~/L\d+$ShortName/)
9236850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of const global data
9237850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # some global data is not mangled in the TU dump: qt_sine_table (Qt 4.8)
9238850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and incorrectly mangled by old ACC versions
9239850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9240850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
92421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
92435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $CheckHeadersOnly)
92445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # support for old ABI dumps
92455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not checkDump(1, "2.17")
92465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not checkDump(2, "2.17"))
92475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
92485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
92495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                {
92505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
92515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    {
92525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        if(link_symbol($ShortName, $LibVersion, "-Deps"))
92535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        {
92545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $MnglName = $ShortName;
92555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
92565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        }
92575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    }
92585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
92595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
92605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
92611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Remangle==1 or $SRemangle==1)
9262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old ABI dumps: some symbols are not mangled in old dumps
9263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # mangle both sets of symbols (old and new)
9264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # NOTE: remangling all symbols by the same mangler
9265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(V|)K/)
9266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Const" attribute
92681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Const"} = 1;
9269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(K|)V/)
9271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Volatile" attribute
92731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Volatile"} = 1;
9274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
92751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(($ClassID and $MnglName!~/\A(_Z|\?)/)
92761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and $CheckHeadersOnly)
92771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and not link_symbol($MnglName, $LibVersion, "-Deps")))
92781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # support for old ABI dumps, GCC >= 4.0
92791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko              # remangling all manually mangled symbols
92801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($MnglName = mangle_symbol($InfoId, $LibVersion, "GCC"))
9281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
92821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
9283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MangledNames{$LibVersion}{$MnglName} = 1;
9284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Remangle==-1)
9288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # remove mangling
9289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MnglName = "";
92901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = "";
9291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $MnglName) {
9293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
92958a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
92968a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        # NOTE: duplicated entries in the ABI Dump
92978a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if(defined $CompleteSignature{$LibVersion}{$MnglName})
92988a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        {
92998a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
93008a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            {
93018a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} eq "p1")
93028a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                {
93038a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    next;
93048a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                }
93058a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
93068a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
93078a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
9308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$MnglName}{"MnglName"})
9309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # NOTE: global data may enter here twice
93101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$MnglName}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
93111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
9312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
931362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.6"))
9314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps
9315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # add "Volatile" attribute
9316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/_Z(K|)V/) {
9317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompleteSignature{$LibVersion}{$MnglName}{"Volatile"}=1;
9318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # symbol and its symlink have same signatures
9321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymVer{$LibVersion}{$MnglName}) {
93221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$MnglName}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9325fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Alias = $CompleteSignature{$LibVersion}{$MnglName}{"Alias"})
9326fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
9327fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Alias}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
93288a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
9329fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SymVer{$LibVersion}{$Alias}) {
9330fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$Alias}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9331fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
9332fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9333fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9334850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
93351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId});
9336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" or $OSgroup eq "windows") {
9338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        translateSymbols(keys(%{$CompleteSignature{$LibVersion}}), $LibVersion);
9339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
9341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
9342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addExtension($LibVersion);
9343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9344850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9345850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
9346850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    delete($SymbolInfo{$LibVersion});
9347850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9348850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
9349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect allocable classes with public exported constructors
9350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or classes with auto-generated or inline-only constructors
93519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and other temp info
9352850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
9353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
935462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
9355850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"}
9356850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"})
9357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Class() { ... } will not be exported
9358850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9360850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly or link_symbol($Symbol, $LibVersion, "-Deps")) {
9361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AllocableClass{$LibVersion}{$ClassName} = 1;
9362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9365850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all imported class methods
9367850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Binary"))
9368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9369850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly)
9370850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
9371850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if(not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
9372850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        or $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
9373850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        { # all symbols except non-virtual inline
9374850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9375850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        }
9376850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9377850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    else {
9378850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
938162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Source")) {
9382850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $ClassMethods{"Source"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
93851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $ClassNames{$LibVersion}{$ClassName} = 1;
9386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9387850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $RetId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
9388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
938962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Base = get_BaseType($RetId, $LibVersion);
9390850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $Base{"Type"}
9391850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and $Base{"Type"}=~/Struct|Class/)
9392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
939362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Name = $TypeInfo{$LibVersion}{$Base{"Tid"}}{"Name"};
9394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Name=~/<([^<>\s]+)>/)
9395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $Tid = getTypeIdByName($1, $LibVersion)) {
9397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ReturnedClass{$LibVersion}{$Tid} = 1;
9398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
9401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ReturnedClass{$LibVersion}{$Base{"Tid"}} = 1;
9402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9405850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Num (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
9406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9407850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $PId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Num}{"type"};
940862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(get_PLevel($PId, $LibVersion)>=1)
9409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
941062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my %Base = get_BaseType($PId, $LibVersion))
9411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
94121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if($Base{"Type"}=~/Struct|Class/)
94131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    {
9414850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ParamClass{$LibVersion}{$Base{"Tid"}}{$Symbol} = 1;
94151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        foreach my $SubId (get_sub_classes($Base{"Tid"}, $LibVersion, 1))
94161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # mark all derived classes
9417850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ParamClass{$LibVersion}{$SubId}{$Symbol} = 1;
94181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        }
9419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
94239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
94249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # mapping {short name => symbols}
94259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Func_ShortName{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"ShortName"}}{$Symbol} = 1;
9426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9427dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $MnglName (keys(%VTableClass))
942874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # reconstruct attributes of v-tables
94299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($MnglName, "_ZTV")==0)
9430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9431dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $ClassName = $VTableClass{$MnglName})
9432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
943374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
943474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
943562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Header"} = $TypeInfo{$LibVersion}{$ClassId}{"Header"};
943674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Class"} = $ClassId;
9437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
94411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
94421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # types
944362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
94441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
944562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"})
94461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
944762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"}) {
944862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
94491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
945062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"Base"})
94511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
945262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
945362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"Base"}}))
94541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                {
945562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BName = $TypeInfo{$LibVersion}{$Bid}{"Name"}) {
945662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $ClassNames{$LibVersion}{$BName} = 1;
94571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    }
94581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
94591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
94601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
94611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
9462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getFirst($$)
9465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Tid) {
9468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return $Tid;
9469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"})
9472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TName_Tid{$LibVersion}{$Name}) {
9474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $TName_Tid{$LibVersion}{$Name};
9475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9478177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Tid;
9479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9480177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_SymbolUsage($$$)
9482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($InfoId, $UsedType, $LibVersion) = @_;
9484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %FuncInfo = %{$SymbolInfo{$LibVersion}{$InfoId}};
9486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $RTid = getFirst($FuncInfo{"Return"}, $LibVersion))
9487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($RTid, $UsedType, $LibVersion);
9489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Return"} = $RTid;
9490177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $FCid = getFirst($FuncInfo{"Class"}, $LibVersion))
9492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($FCid, $UsedType, $LibVersion);
9494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Class"} = $FCid;
9495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."*const", $LibVersion))
9497177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer
9498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId, $UsedType, $LibVersion);
9499177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9500177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId_C = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."const*const", $LibVersion))
9501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer (const method)
9502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId_C, $UsedType, $LibVersion);
9503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $PPos (keys(%{$FuncInfo{"Param"}}))
9506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $PTid = getFirst($FuncInfo{"Param"}{$PPos}{"type"}, $LibVersion))
9508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($PTid, $UsedType, $LibVersion);
9510177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $FuncInfo{"Param"}{$PPos}{"type"} = $PTid;
9511177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $TPos (keys(%{$FuncInfo{"TParam"}}))
9514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $TPName = $FuncInfo{"TParam"}{$TPos}{"name"};
9516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($TTid, $UsedType, $LibVersion);
9518177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9519177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9520177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_TypeUsage($$$)
9523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($TypeId, $UsedType, $LibVersion) = @_;
952562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $TypeId) {
9526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9527989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($UsedType->{$TypeId})
9529989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # already registered
9530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9531989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
953362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TInfo = get_Type($TypeId, $LibVersion);
9534850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TInfo{"Type"})
9535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $NS = $TInfo{"NameSpace"})
9537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $NSTid = $TName_Tid{$LibVersion}{$NS}) {
9539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($NSTid, $UsedType, $LibVersion);
9540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TInfo{"Type"}=~/\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\Z/)
9544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9546850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"}=~/\A(Struct|Class)\Z/)
9547989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $BaseId (keys(%{$TInfo{"Base"}})) {
9549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($BaseId, $UsedType, $LibVersion);
9550989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9551850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $TPos (keys(%{$TInfo{"TParam"}}))
9552850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
9553850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    my $TPName = $TInfo{"TParam"}{$TPos}{"name"};
9554850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($TTid, $UsedType, $LibVersion);
9556850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9557850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
95581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9559850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            foreach my $Memb_Pos (keys(%{$TInfo{"Memb"}}))
9560989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $MTid = getFirst($TInfo{"Memb"}{$Memb_Pos}{"type"}, $LibVersion))
9562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($MTid, $UsedType, $LibVersion);
9564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TInfo{"Memb"}{$Memb_Pos}{"type"} = $MTid;
9565989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
95661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9567850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"} eq "FuncPtr"
9568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "MethodPtr"
9569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "Func")
9570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9571850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9573989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $PPos (keys(%{$TInfo{"Param"}}))
9575989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
9576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $PTid = $TInfo{"Param"}{$PPos}{"type"}) {
9577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($PTid, $UsedType, $LibVersion);
9578989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
9579989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9581177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "FieldPtr")
9582177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9583177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9589177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9590177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "MethodPtr")
9591177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9592177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9595177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9597850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($TInfo{"Type"}=~/\A(Const|ConstVolatile|Volatile|Pointer|Ref|Restrict|Array|Typedef)\Z/)
9598989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
9599177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9600177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $BTid = getFirst($TInfo{"BaseType"}, $LibVersion))
9601177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($BTid, $UsedType, $LibVersion);
9603177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $BTid;
9604177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
96051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
9606177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9607177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # Intrinsic, TemplateParam, TypeName, SizeOf, etc.
9608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
96091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
96101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
96111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
96121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9613850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub selectSymbol($$$$)
961435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko{ # select symbol to check or to dump
9615850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Symbol, $SInfo, $Level, $LibVersion) = @_;
9616850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
961735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($Level eq "Dump")
961835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    {
961935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($SInfo->{"Virt"} or $SInfo->{"PureVirt"})
962035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        { # TODO: check if this symbol is from
962135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko          # base classes of other target symbols
962235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            return 1;
962335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
962435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    }
962535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko
9626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $STDCXX_TESTING and $Symbol=~/\A(_ZS|_ZNS|_ZNKS)/)
9627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # stdc++ interfaces
9628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return 0;
96290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
9630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Target = 0;
9632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Header = $SInfo->{"Header"}) {
9633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Target = (is_target_header($Header, 1) or is_target_header($Header, 2));
9634850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
96358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtendedCheck)
96368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
9637c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        if(index($Symbol, "external_func_")==0) {
96388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Target = 1;
96398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
96408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
9641177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckHeadersOnly or $Level eq "Source")
9642850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Target)
9644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9645850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Dump")
9646850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # dumped
9647850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($BinaryOnly)
96480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
9649850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(not $SInfo->{"InLine"} or $SInfo->{"Data"}) {
96500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        return 1;
96510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
96520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
9653850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else {
9654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9655850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
96560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
9657850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Source")
9658850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9659850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9660850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9661850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Binary")
9662850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9663850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SInfo->{"InLine"} or $SInfo->{"Data"}
9664850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $SInfo->{"Virt"} or $SInfo->{"PureVirt"}) {
9665850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9666850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9667850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9668850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9669850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
9670850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
9671850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # library is available
9672850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(link_symbol($Symbol, $LibVersion, "-Deps"))
9673850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # exported symbols
9674850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
9675850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9676850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Dump")
9677850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # dumped
967835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            if($BinaryOnly)
967935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            {
968035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($SInfo->{"Data"})
968135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                {
968235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    if($Target) {
968335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                        return 1;
968435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    }
9685850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9686850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
968735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            else
968835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # SrcBin
9689850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9690850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9691850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9692850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9693850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9694850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Source")
9695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
969601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"} or $SInfo->{"InLine"}
9697ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($SInfo, $LibVersion))
969835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # skip LOCAL symbols
969935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($Target) {
970035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    return 1;
970135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                }
97020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
97030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
9704850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Binary")
9705850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
9706850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"})
9707850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9708850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9709850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9711850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9712850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
97130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
97140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
97150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
97160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
9717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub cleanDump($)
9718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # clean data
9719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
97201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
9721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9722177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}}))
9723177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9724177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9725177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9726177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
97271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9728177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $MnglName)
9729177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
97301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9733850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
9734177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ShortName)
9735177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9736989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9737989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
9738989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9739850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($MnglName eq $ShortName)
9740850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # remove duplicate data
97411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"MnglName"});
9742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9743850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})) {
9744850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"Param"});
9745850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
974601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}})) {
974701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"TParam"});
974801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9749f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId}{"Type"});
9750850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
975162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
9752850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9753177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}}))
9754177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9755177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9756177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9757177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
975801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid}{"Tid"});
975962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Attr ("Header", "Line", "Size", "NameSpace")
9760850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
976162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $TypeInfo{$LibVersion}{$Tid}{$Attr}) {
976262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{$Attr});
9763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
976501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}{"TParam"}})) {
976601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TParam"});
976701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9768850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
976962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
977062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
977128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub pickType($$)
977262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
977362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
97749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
97759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $Dupl = $TypeTypedef{$LibVersion}{$Tid})
97769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
97779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$Dupl})
97789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
97799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Dupl}{"Name"} eq $TypeInfo{$LibVersion}{$Tid}{"Name"})
97809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # duplicate
97819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return 0;
97829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
97839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
97849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
97859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
978628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"};
978728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
978828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isBuiltIn($THeader)) {
978928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
979028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
979128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
979228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/) {
979328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
979428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
979528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
979628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isAnon($TypeInfo{$LibVersion}{$Tid}{"Name"})) {
979728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
979828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
979928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
980028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(selfTypedef($Tid, $LibVersion)) {
980128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
980228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
980328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
980428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(not isTargetType($Tid, $LibVersion)) {
980528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
980628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
980728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
980828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 0;
980928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko}
981028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
981128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub isTargetType($$)
981228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko{
981328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
981428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
981528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/)
981628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    { # derived
981728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 1;
981828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
981928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
982062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"})
98218a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    { # NOTE: header is defined to source if undefined (DWARF dumps)
982228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(not is_target_header($THeader, $LibVersion))
982328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        { # from target headers
982428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
9825850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9826850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
98278a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    else
98288a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    { # NOTE: if type is defined in source
98298a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($UsedDump{$LibVersion}{"Public"})
98308a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        {
98318a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(isPrivateABI($Tid, $LibVersion)) {
98328a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                return 0;
98338a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
98348a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            else {
98358a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                return 1;
98368a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
98378a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
98388a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        else {
98398a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            return 0;
98408a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
98412c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
984228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
98431fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalTypes)
98441fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    {
98451fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$Tid}{"Name"}=~/($SkipInternalTypes)/)
98461fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        {
98471fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            return 0;
98481fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
98491fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
98501fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
985128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 1;
9852850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9853850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub remove_Unused($$)
9855850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # remove unused data types from the ABI dump
9856850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($LibVersion, $Kind) = @_;
9857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %UsedType = ();
9859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9860177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $InfoId (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}}))
9861850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9862177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_SymbolUsage($InfoId, \%UsedType, $LibVersion);
9863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extended")
9872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
987328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            if(pickType($Tid, $LibVersion))
9874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9875177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Tree = ();
9876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($Tid, \%Tree, $LibVersion);
9877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Tmpl = 0;
9879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (sort {int($a)<=>int($b)} keys(%Tree))
9880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
9884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Tmpl = 1;
9885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        last;
9886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not $Tmpl)
9889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%Tree)) {
9891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $UsedType{$_} = 1;
9892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %Delete = ();
9899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove unused types
9902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9905989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extra")
9908850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Tree = ();
9910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($Tid, \%Tree, $LibVersion);
9911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%Tree))
9913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Delete{$Tid} = 1;
9918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last;
9919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9920850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9921989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            # remove type
9925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9929177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Kind eq "Extra")
9930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove duplicates
9931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($UsedType{$Tid})
9934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # All & Extended
9935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"};
9939177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName_Tid{$LibVersion}{$Name} ne $Tid) {
9941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid});
9942989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
9943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9944177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9945177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9946177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (keys(%Delete))
9947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid});
9949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9951177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9952177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_Completeness($$)
9953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Info, $LibVersion) = @_;
9955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # data types
9957177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Memb"})
9958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Memb"}}))
9960850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Memb"}{$Pos}{"type"}) {
9962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Memb"}{$Pos}{"type"}, $LibVersion);
9963850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Base"})
996762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
9968177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Bid (keys(%{$Info->{"Base"}})) {
9969177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_TypeInfo($Bid, $LibVersion);
997062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
9971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"BaseType"}) {
9973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"BaseType"}, $LibVersion);
9974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"TParam"})
9976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9977177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"TParam"}}))
9978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9979177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $TName = $Info->{"TParam"}{$Pos}{"name"};
9980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\A\(.+\)(true|false|\d.*)\Z/) {
9981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9983177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName eq "_BoolType") {
9984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\Asizeof\(/) {
9987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Tid = $TName_Tid{$LibVersion}{$TName}) {
9990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Tid, $LibVersion);
9991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            else
9993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $Debug) {
9995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    printMsg("WARNING", "missed type $TName");
9996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9997850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # symbols
10002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Param"})
10003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Param"}}))
10005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
10006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Param"}{$Pos}{"type"}) {
10007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Param"}{$Pos}{"type"}, $LibVersion);
10008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
1000962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1001062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
10011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Return"}) {
10012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Return"}, $LibVersion);
10013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Class"}) {
10015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Class"}, $LibVersion);
10016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
10018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_TypeInfo($$)
10020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
10021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
10022850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
10023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $CheckedTypeInfo{$LibVersion}{$Tid}) {
10024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
10025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $CheckedTypeInfo{$LibVersion}{$Tid} = 1;
10027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$Tid})
10029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $TypeInfo{$LibVersion}{$Tid}{"Name"}) {
10031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            printMsg("ERROR", "missed type name ($Tid)");
10032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
10033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_Completeness($TypeInfo{$LibVersion}{$Tid}, $LibVersion);
10034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else {
10036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        printMsg("ERROR", "missed type id $Tid");
10037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10038850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
10039850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1004062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selfTypedef($$)
10041850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
1004262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1004362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = get_Type($TypeId, $LibVersion);
10044850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type{"Type"} eq "Typedef")
10045dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
10046f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base = get_OneStep_BaseType($TypeId, $TypeInfo{$LibVersion});
10047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base{"Type"}=~/Class|Struct/)
10048850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10049850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Type{"Name"} eq $Base{"Name"}) {
10050850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
10051850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10052850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Type{"Name"}=~/::(\w+)\Z/)
10053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10054850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Type{"Name"} eq $Base{"Name"}."::".$1)
10055850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # QPointer<QWidget>::QPointer
10056850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
10057850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10058850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10059dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
10060dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
10061850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
10062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addExtension($)
10065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
100661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
100678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
10068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1006928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(pickType($Tid, $LibVersion))
10070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
100718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$Tid}{"Name"};
100728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $TName=~s/\A(struct|union|class|enum) //;
100738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Symbol = "external_func_".$TName;
1007462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1007562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Symbol}} = (
1007662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Header" => "extended.h",
1007762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "ShortName" => $Symbol,
1007862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "MnglName" => $Symbol,
1007962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param" => { 0 => { "type"=>$Tid, "name"=>"p1" } }
1008062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1008162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
100828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ExtendedSymbols{$Symbol} = 1;
100838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
100848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Source"}{$Symbol} = 1;
10085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
100878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $ExtendedSymbols{"external_func_0"} = 1;
100888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Binary"}{"external_func_0"} = 1;
100898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Source"}{"external_func_0"} = 1;
10090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod($$$)
10093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1009562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $BaseClass_Id (keys(%{$TypeInfo{$LibVersion}{$ClassId}{"Base"}}))
10096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VirtMethodInClass = findMethod_Class($VirtFunc, $BaseClass_Id, $LibVersion)) {
10098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInClass;
10099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $VirtMethodInBaseClasses = findMethod($VirtFunc, $BaseClass_Id, $LibVersion)) {
10101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInBaseClasses;
10102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod_Class($$$)
10108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1011062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
10111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not defined $VirtualTable{$LibVersion}{$ClassName});
10112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetSuffix = get_symbol_suffix($VirtFunc, 1);
10113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetShortName = $CompleteSignature{$LibVersion}{$VirtFunc}{"ShortName"};
10114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for interface with the same parameters suffix (overridden)
10116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetSuffix eq get_symbol_suffix($Candidate, 1))
10117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10118e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"Destructor"})
10119e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10120989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Candidate}{"Destructor"})
10121989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($VirtFunc=~/D0E/ and $Candidate=~/D0E/)
10123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D1E/ and $Candidate=~/D1E/)
10124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D2E/ and $Candidate=~/D2E/)) {
10125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return $Candidate;
10126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10129e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            else
10130e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TargetShortName eq $CompleteSignature{$LibVersion}{$Candidate}{"ShortName"}) {
10132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
10133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
101401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub registerVTable($)
10141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
101421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
101431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
10144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
101451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Virt"}
101461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{$LibVersion}{$Symbol}{"PureVirt"})
10147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1014862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"Class"}}{"Name"};
10149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $STDCXX_TESTING and $ClassName=~/\A(std::|__cxxabi)/);
101501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}
101511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Symbol=~/D2E/)
10152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual D2-destructors are marked as "virt" in the dump
10153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # virtual D2-destructors are NOT marked as "virt" in the dump
10154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # both destructors are not presented in the v-table
10155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
10156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
101571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
10158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $VirtualTable{$LibVersion}{$ClassName}{$MnglName} = 1;
10159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub registerOverriding($)
10164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Classes = keys(%{$VirtualTable{$LibVersion}});
10167850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Classes = sort {int($TName_Tid{$LibVersion}{$a})<=>int($TName_Tid{$LibVersion}{$b})} @Classes;
10168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (@Classes)
10169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $VirtFunc (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
101721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"PureVirt"})
101731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # pure virtuals
101741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                next;
101751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
101761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $ClassId = $TName_Tid{$LibVersion}{$ClassName};
101771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Overridden = findMethod($VirtFunc, $ClassId, $LibVersion))
10178850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10179850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Overridden}{"Virt"}
10180850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $CompleteSignature{$LibVersion}{$Overridden}{"PureVirt"})
10181850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # both overridden virtual methods
10182850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and implemented pure virtual methods
10183850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$VirtFunc}{"Override"} = $Overridden;
10184850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $OverriddenMethods{$LibVersion}{$Overridden}{$VirtFunc} = 1;
10185850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    delete($VirtualTable{$LibVersion}{$ClassName}{$VirtFunc}); # remove from v-table model
10186850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not keys(%{$VirtualTable{$LibVersion}{$ClassName}})) {
10190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($VirtualTable{$LibVersion}{$ClassName});
10191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setVirtFuncPositions($)
10196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{$LibVersion}}))
10199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my ($Num, $Rel) = (1, 0);
10201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Funcs = sort keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UsedDump{$LibVersion}{"DWARF"}) {
10205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @Funcs;
10206fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10207fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
10208fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @Funcs;
10209fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10210fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $VirtFunc (@Funcs)
10211fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
10212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10213fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $CompleteSignature{$LibVersion}{$VirtFunc}{"VirtPos"};
10214fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10215fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $Num++;
10217fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10219fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # set relative positions
10220fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(defined $VirtualTable{1}{$ClassName} and defined $VirtualTable{1}{$ClassName}{$VirtFunc}
10221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and defined $VirtualTable{2}{$ClassName} and defined $VirtualTable{2}{$ClassName}{$VirtFunc})
10222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # relative position excluding added and removed virtual functions
10223fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $CompleteSignature{1}{$VirtFunc}{"Override"}
10224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $CompleteSignature{2}{$VirtFunc}{"Override"}) {
10225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $CompleteSignature{$LibVersion}{$VirtFunc}{"RelPos"} = $Rel++;
10226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
10227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
102311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{$LibVersion}}))
10232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $AbsNum = 1;
102341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $VirtFunc (getVTable_Model($TName_Tid{$LibVersion}{$ClassName}, $LibVersion)) {
10235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $VirtualTable_Model{$LibVersion}{$ClassName}{$VirtFunc} = $AbsNum++;
10236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_classes($$$)
10241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
10243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $Class_SubClasses{$LibVersion}{$ClassId});
10244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Subs = ();
10245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubId (keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubSubId (get_sub_classes($SubId, $LibVersion, $Recursive)) {
10250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Subs, $SubSubId);
10251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Subs, $SubId);
10254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Subs;
10256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_base_classes($$$)
10259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
1026162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %ClassType = get_Type($ClassId, $LibVersion);
10262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $ClassType{"Base"});
10263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = ();
10264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (sort {int($ClassType{"Base"}{$a}{"pos"})<=>int($ClassType{"Base"}{$b}{"pos"})}
10265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    keys(%{$ClassType{"Base"}}))
10266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
102681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubBaseId (get_base_classes($BaseId, $LibVersion, $Recursive)) {
10270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Bases, $SubBaseId);
10271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Bases, $BaseId);
10274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Bases;
10276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
102781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Model($$)
102791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # return an ordered list of v-table elements
10280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Elements = ();
10283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases, $ClassId)
10284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1028562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10286850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10287850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName})
10288850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10289fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my @VFuncs = keys(%{$VirtualTable{$LibVersion}{$BName}});
10290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10291fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @VFuncs;
10292fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10293fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10294fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @VFuncs;
10295fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10296fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $VFunc (@VFuncs) {
10297850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    push(@Elements, $VFunc);
10298850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10299850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Elements;
10303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVShift($$)
10306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VShift = 0;
10310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1031262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10314850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName}) {
10315850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $VShift+=keys(%{$VirtualTable{$LibVersion}{$BName}});
10316850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VShift;
10320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getShift($$)
10323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 0);
10326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Shift = 0;
10327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1032962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Size = $TypeInfo{$LibVersion}{$BaseId}{"Size"})
10330dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
10331dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Size!=1)
10332dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # not empty base class
10333dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $Shift+=$Size;
10334dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
10335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Shift;
10338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Size($$)
103411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # number of v-table elements
10342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
103431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Size = 0;
103441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # three approaches
103451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # real size
103471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(my %VTable = getVTable_Real($ClassName, $LibVersion)) {
103481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%VTable);
103491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # shared library symbol size
103531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Size = getSymbolSize($ClassVTable{$ClassName}, $LibVersion)) {
103541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size /= $WORD_SIZE{$LibVersion};
103551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
103581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # model size
103591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $VirtualTable_Model{$LibVersion}{$ClassName}) {
103601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%{$VirtualTable_Model{$LibVersion}{$ClassName}}) + 2;
103611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
103621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
103631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Size;
10364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCopyingClass($$)
10367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1036962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return $TypeInfo{$LibVersion}{$TypeId}{"Copied"};
10370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLeafClass($$)
10373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (not keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}));
10376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub havePubFields($)
10379dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check structured type for public fields
10380dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return isAccessible($_[0], {}, 0, -1);
10381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAccessible($$$$)
10384dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check interval in structured type for public fields
10385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $Skip, $Start, $End) = @_;
10386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($End==-1) {
10388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $End = keys(%{$TypePtr->{"Memb"}})-1;
10389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10390a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko    foreach my $MemPos (sort {int($a)<=>int($b)} keys(%{$TypePtr->{"Memb"}}))
10391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Skip and $Skip->{$MemPos})
10393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip removed/added fields
10394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($MemPos)>=$Start and int($MemPos)<=$End)
10397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isPublic($TypePtr, $MemPos)) {
10399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return ($MemPos+1);
10400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isReserved($)
10407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # reserved fields == private
10408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MName = $_[0];
10409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/reserved|padding|f_spare/i) {
10410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10412d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($MName=~/\A[_]*(spare|pad|unused|dummy)[_\d]*\Z/i) {
10413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/(pad\d+)/i) {
10416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isPublic($$)
10422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $FieldPos) = @_;
10424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
10426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
10427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypePtr->{"Memb"}{$FieldPos}{"access"})
10428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by name in C language
10429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: add other methods to detect private members
10430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
10431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MName=~/priv|abidata|parent_object/i)
10432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C-styled private data
10433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(lc($MName) eq "abi")
10436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # ABI information/reserved field
10437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isReserved($MName))
10440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # reserved fields
10441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypePtr->{"Memb"}{$FieldPos}{"access"} ne "private")
10446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by access in C++ language
10447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Real($$)
104531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
104551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
104561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
1045762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type = get_Type($ClassId, $LibVersion);
104581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Type{"VTable"}) {
104591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return %{$Type{"VTable"}};
104601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
104611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ();
104631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
104651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables($)
104661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
104671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ClassName = $_[0];
104681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Res = cmpVTables_Real($ClassName, 1);
104691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Res==-1) {
104701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Res = cmpVTables_Model($ClassName);
104711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Res;
104731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
10475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVTables_Model($)
10476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ClassName = $_[0];
104781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $Symbol (keys(%{$VirtualTable_Model{1}{$ClassName}}))
10479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
104801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol}) {
10481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
10482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables_Real($$)
10488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $Strong) = @_;
104901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"cmpVTables_Real"}{$Strong}{$ClassName}) {
104911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"cmpVTables_Real"}{$Strong}{$ClassName};
10492dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
104931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_Old = getVTable_Real($ClassName, 1);
104941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_New = getVTable_Real($ClassName, 2);
104951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not %VTable_Old or not %VTable_New)
10496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old ABI dumps
104971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = -1);
10498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Indexes = map {$_=>1} (keys(%VTable_Old), keys(%VTable_New));
10500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Offset (sort {int($a)<=>int($b)} keys(%Indexes))
10501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_Old{$Offset})
10503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 < v-table v.2
105041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = $Strong);
10505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry1 = $VTable_Old{$Offset};
105071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_New{$Offset})
10508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 > v-table v.2
105091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = ($Strong or $Entry1!~/__cxa_pure_virtual/));
10510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry2 = $VTable_New{$Offset};
10512ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry1 = simpleVEntry($Entry1);
10514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry2 = simpleVEntry($Entry2);
105151fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
105168a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($Entry1=~/ 0x/ or $Entry2=~/ 0x/)
105171fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        { # NOTE: problem with vtable-dumper
105181fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            next;
105191fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
105201fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
10521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Entry1 ne $Entry2)
10522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register as changed
10523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry1=~/::([^:]+)\Z/)
10524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
10525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $M1 = $1;
10526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Entry2=~/::([^:]+)\Z/)
10527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $M2 = $1;
10529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($M1 eq $M2)
10530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # overridden
10531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10535989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(differentDumps("G"))
10536989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
10537989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Entry1=~/\A\-(0x|\d+)/ and $Entry2=~/\A\-(0x|\d+)/)
10538989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10539989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.6.1: -0x00000000000000010
10540989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.7.0: -16
10541989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    next;
10542989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
10543989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
105441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 1);
10545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 0);
10548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVTables($)
10551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # merging v-tables without diagnostics
105521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
10553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{1}}))
10554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10555e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10556e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        if(isPrivateABI($ClassId, 1)) {
10557e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko            next;
10558e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        }
10559e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
105601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($VTableChanged_M{$ClassName})
10561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # already registered
10562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(cmpVTables_Real($ClassName, 0)==1)
10565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
10567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (@Affected)
10568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
105691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Virtual_Table_Changed_Unknown"}{$ClassName}}=(
10570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$ClassName,
10571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$ClassName);
10572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeBases($)
10578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
105791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
105801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{1}}))
10581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added and removed virtual functions
105821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId);
10584e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10585e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        if(isPrivateABI($ClassId, 1)) {
10586e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko            next;
10587e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        }
10588e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10589dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{2}{$ClassName})
10590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{2}{$ClassName}}))
10592dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
105931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{1}{$ClassName}
105941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{1}{$ClassName}{$Symbol})
10595dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # added to v-table
105961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{1}{$Symbol}
105971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{1}{$Symbol}{"Virt"})
105981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.1
105991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10600dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $AddedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10605dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{1}{$ClassName})
10606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{1}{$ClassName}}))
10608dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{2}{$ClassName}
106101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{2}{$ClassName}{$Symbol})
10611dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # removed from v-table
106121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$Symbol}
106131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{2}{$Symbol}{"Virt"})
106141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.2
106151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10616dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $RemovedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
106211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
106221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
1062362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Class_Type = get_Type($ClassId, 1);
106241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$ClassName}}))
106251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # check replacements, including pure virtual methods
106261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $AddedPos = $VirtualTable{2}{$ClassName}{$AddedVFunc};
106271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$ClassName}}))
10628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $RemovedPos = $VirtualTable{1}{$ClassName}{$RemovedVFunc};
106301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($AddedPos==$RemovedPos)
106311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$AddedVFunc} = $RemovedVFunc;
106331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$RemovedVFunc} = $AddedVFunc;
106341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        last; # other methods will be reported as "added" or "removed"
10635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
106371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $RemovedVFunc = $VirtualReplacement{$AddedVFunc})
10638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(lc($AddedVFunc) eq lc($RemovedVFunc))
106401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # skip: DomUi => DomUI parameter (Qt 4.2.3 to 4.3.0)
10641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
106431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ProblemType = "Virtual_Replacement";
106441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @Affected = ($RemovedVFunc);
106451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
106461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # pure methods
106471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not isUsedClass($ClassId, 1, $Level))
106481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # not a parameter of some exported method
106491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemType = "Pure_Virtual_Replacement";
106529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
106539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        # affected all methods (both virtual and non-virtual ones)
106549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
106559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        push(@Affected, keys(%{$OverriddenMethods{1}{$RemovedVFunc}}));
106561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
106579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $VTableChanged_M{$ClassName}=1;
106581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $AffectedInt (@Affected)
106591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
106601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$AffectedInt}{"PureVirt"})
106611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # affected exported methods only
106621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
106631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(not symbolFilter($AffectedInt, 1, "Affected", $Level)) {
106659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
106669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
106671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$AffectedInt}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
106681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$Class_Type{"Name"},
106691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2),
106701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>get_Signature($RemovedVFunc, 1));
106711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
10672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1067662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.0")
1067762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.0"))
106781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # support for old ABI dumps
106799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # "Base" attribute introduced in ACC 1.22 (ABI dump 2.0 format)
10680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
106821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (sort keys(%{$ClassNames{1}}))
10683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
106841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_Old = $TName_Tid{1}{$ClassName};
10685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId_Old);
10686e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10687e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        if(isPrivateABI($ClassId_Old, 1)) {
10688e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko            next;
10689e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        }
10690e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
10691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isCreatable($ClassId_Old, 1))
10692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip classes without public constructors (including auto-generated)
10693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # example: class has only a private exported or private inline constructor
10694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ClassName=~/>/)
10697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip affected template instances
10698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1070062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_Old = get_Type($ClassId_Old, 1);
107011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_New = $TName_Tid{2}{$ClassName};
10702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $ClassId_New) {
10703850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
10704850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
1070562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_New = get_Type($ClassId_New, 2);
10706850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Class_New{"Type"}!~/Class|Struct/)
10707850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # became typedef
10708850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Binary") {
10709850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                next;
10710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10711850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Source")
10712850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10713f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Class_New = get_PureType($ClassId_New, $TypeInfo{2});
10714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Class_New{"Type"}!~/Class|Struct/) {
10715850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
10716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ClassId_New = $Class_New{"Tid"};
10718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
10720ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10721ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $Class_New{"Size"} or not $Class_Old{"Size"})
10722ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # incomplete info in the ABI dump
10723ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
10724ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
10725ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10726ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_Old = sort {$Class_Old{"Base"}{$a}{"pos"}<=>$Class_Old{"Base"}{$b}{"pos"}} keys(%{$Class_Old{"Base"}});
10728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_New = sort {$Class_New{"Base"}{$a}{"pos"}<=>$Class_New{"Base"}{$b}{"pos"}} keys(%{$Class_New{"Base"}});
10729f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10730f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_Old = map {$TypeInfo{1}{$_}{"Name"} => uncover_typedefs($TypeInfo{1}{$_}{"Name"}, 1)} @Bases_Old;
10731f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_New = map {$TypeInfo{2}{$_}{"Name"} => uncover_typedefs($TypeInfo{2}{$_}{"Name"}, 2)} @Bases_New;
10732f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($BNum1, $BNum2) = (1, 1);
10734f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @Bases_Old;
10735f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @Bases_New;
1073674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_Old = map {get_ShortClass($_, 1) => 1} @Bases_Old;
1073774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_New = map {get_ShortClass($_, 2) => 1} @Bases_New;
10738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_Old = getShift($ClassId_Old, 1);
10739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_New = getShift($ClassId_New, 2);
10740f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BaseId_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @Bases_New;
10741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Added, $Removed) = (0, 0);
10742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_Old = ();
10743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_Old)
10744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1074562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10746f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_New{$Tr_Old{$BaseName}}) {
10747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_Old, $BaseId);
10748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10749f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_New{$Tr_Old{$BaseName}}
1075074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_New{get_ShortClass($BaseId, 1)})
10751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # removed base
10752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Removed_Base_Class";
107541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
107551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
107561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
107571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
107581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
107591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
107601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
107621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
107631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{1}{$BaseName}})
107661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
107671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
107681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
107691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10775f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10776f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10777f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10778f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10779f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10780f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
107879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
107881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Removed+=1;
10796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_New = ();
10799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_New)
10800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1080162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{2}{$BaseId}{"Name"};
10802f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_Old{$Tr_New{$BaseName}}) {
10803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_New, $BaseId);
10804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10805f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_Old{$Tr_New{$BaseName}}
1080674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_Old{get_ShortClass($BaseId, 2)})
10807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # added base
10808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Added_Base_Class";
108101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
108111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
108121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
108131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
108141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
108151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
108161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
108171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
108181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
108191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{2}{$BaseName}})
108221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
108231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
108241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
108251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
108281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10831f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10832f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10833f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10834f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10835f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10836f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
108419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
108439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
108441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Added+=1;
10852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
108541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
108551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
108561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            ($BNum1, $BNum2) = (1, 1);
10857f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @StableBases_Old;
10858f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @StableBases_New;
108591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $BaseId (@Bases_Old)
10860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1086162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10862f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(my $NewPos = $BaseRelPos_New{$Tr_Old{$BaseName}})
108631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
10864f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $BaseNewId = $BaseId_New{$Tr_Old{$BaseName}};
10865f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $OldPos = $BaseRelPos_Old{$Tr_Old{$BaseName}};
108661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($NewPos!=$OldPos)
108671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed position of the base class
108681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Position"}{"this"}}=(
108741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName,
108761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$OldPos-1,
108771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Value"=>$NewPos-1  );
108781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Class_Old{"Base"}{$BaseId}{"virtual"}
108811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and not $Class_New{"Base"}{$BaseNewId}{"virtual"})
108821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became non-virtual base
108831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Non_Virtually_Inherited"}{"this->".$BaseName}}=(
108891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $Class_Old{"Base"}{$BaseId}{"virtual"}
108941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Class_New{"Base"}{$BaseNewId}{"virtual"})
108951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became virtual base
108961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Virtually_Inherited"}{"this->".$BaseName}}=(
109021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
109041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
109081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # detect size changes in base classes
109091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Shift_Old!=$Shift_New)
109101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # size of allocable class
109111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $BaseId (@StableBases_Old)
109121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # search for changed base
1091362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %BaseType = get_Type($BaseId, 1);
1091462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Size_Old = $TypeInfo{1}{$BaseId}{"Size"};
10915f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $Size_New = $TypeInfo{2}{$BaseId_New{$Tr_Old{$BaseType{"Name"}}}}{"Size"};
109161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Size_Old ne $Size_New
109171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Size_Old and $Size_New)
10918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
10919d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        my $ProblemType = undef;
109201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isCopyingClass($BaseId, 1)) {
109211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Size_Of_Copying_Class";
10922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($AllocableClass{1}{$BaseType{"Name"}})
109241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Size_New>$Size_Old)
109261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # increased size
109271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Increased";
109281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
109291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            else
109301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # decreased size
109311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Decreased";
109321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                if(not havePubFields(\%Class_Old))
109331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # affected class has no public members
109341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
109351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next if(not $ProblemType);
109391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # base class size changes affecting current class
109419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{$ProblemType}{"this->".$BaseType{"Name"}}}=(
109451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$BaseType{"Name"},
109461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseType{"Name"},
109471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Size"=>$Size_Old*$BYTE_SIZE,
109481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Size"=>$Size_New*$BYTE_SIZE  );
109491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10953f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(defined $VirtualTable_Model{1}{$ClassName}
109541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            and cmpVTables_Real($ClassName, 1)==1
10955f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and my @VFunctions = keys(%{$VirtualTable_Model{1}{$ClassName}}))
109561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # compare virtual tables size in base classes
109571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_Old = getVShift($ClassId_Old, 1);
109581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_New = getVShift($ClassId_New, 2);
109591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($VShift_Old ne $VShift_New)
109601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # changes in the base class or changes in the list of base classes
109611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_Old = get_base_classes($ClassId_Old, 1, 1);
109621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_New = get_base_classes($ClassId_New, 2, 1);
109631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    ($BNum1, $BNum2) = (1, 1);
10964f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %StableBase = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @AllBases_New;
109651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $BaseId (@AllBases_Old)
10966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1096762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %BaseType = get_Type($BaseId, 1);
10968f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(not $StableBase{$Tr_Old{$BaseType{"Name"}}})
109691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # lost base
109701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
10971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_Old = getVTable_Size($BaseType{"Name"}, 1);
109731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_New = getVTable_Size($BaseType{"Name"}, 2);
109741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($VSize_Old!=$VSize_New)
10975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
10976850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            foreach my $Symbol (@VFunctions)
10977f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            { # TODO: affected non-virtual methods?
10978f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol})
109791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # Removed_Virtual_Method, will be registered in mergeVirtualTables()
109801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
10981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
10982850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($VirtualTable_Model{2}{$ClassName}{$Symbol}-$VirtualTable_Model{1}{$ClassName}{$Symbol}==0)
109831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # skip interfaces that have not changed the absolute virtual position
109841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
109851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10986850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
10987850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
109881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
109891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$BaseType{"Name"}} = 1;
109901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$ClassName} = 1;
109911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$AddedInt_Virt{$Level}{$BaseType{"Name"}}}))
109921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: added virtual functions
109931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
109941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Added_Virtual_Method";
109951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{2}{$VirtFunc}{"PureVirt"}) {
109961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Added_Pure_Virtual_Method";
109971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
10998850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 2)}}=(
109991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 2)  );
110011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
110021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$RemovedInt_Virt{$Level}{$BaseType{"Name"}}}))
110031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: removed virtual functions
110041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
110051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Removed_Virtual_Method";
110061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{1}{$VirtFunc}{"PureVirt"}) {
110071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Removed_Pure_Virtual_Method";
110081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
11009850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 1)}}=(
110101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 1)  );
11012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCreatable($$)
11023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
1102562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($AllocableClass{$LibVersion}{$TypeInfo{$LibVersion}{$ClassId}{"Name"}}
11026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isCopyingClass($ClassId, $LibVersion)) {
11027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
11030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Fix for incomplete data: if this class has
11031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # a base class then it should also has a constructor
11032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReturnedClass{$LibVersion}{$ClassId})
11035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # returned by some method of this class
11036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or any other class
11037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
110421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isUsedClass($$$)
11043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
110441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($ClassId, $LibVersion, $Level) = @_;
11045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$ParamClass{$LibVersion}{$ClassId}}))
11046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # parameter of some exported method
11047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1104962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1105062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(keys(%{$ClassMethods{$Level}{$LibVersion}{$CName}}))
11051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # method from target class
11052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
110571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVirtualTables($$)
11058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # check for changes in the virtual table
110591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Interface, $Level) = @_;
110601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # affected methods:
11061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - virtual
11062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - pure-virtual
11063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - non-virtual
11064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompleteSignature{1}{$Interface}{"Data"})
11065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # global data is not affected
11066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
11067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Class_Id = $CompleteSignature{1}{$Interface}{"Class"};
110691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Class_Id) {
110701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
1107262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{1}{$Class_Id}{"Name"};
110731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(cmpVTables_Real($CName, 1)==0)
110741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # no changes
110751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
110761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
110771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $CheckedTypes{$Level}{$CName} = 1;
110781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
110791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Binary-level
110801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Interface}{"PureVirt"}
110811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not isUsedClass($Class_Id, 1, $Level))
110821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # pure virtuals should not be affected
110830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # if there are no exported methods using this class
110841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return;
110851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
110860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
110870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach my $Func (keys(%{$VirtualTable{1}{$CName}}))
110880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
110890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $VirtualTable{2}{$CName}{$Func}
110900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and defined $CompleteSignature{2}{$Func})
110910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
110920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(not $CompleteSignature{1}{$Func}{"PureVirt"}
110930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$Func}{"PureVirt"})
110940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became pure virtual
110950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Pure"}{$tr_name{$Func}}}=(
110960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
110970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
110980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
110990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($CompleteSignature{1}{$Func}{"PureVirt"}
111010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and not $CompleteSignature{2}{$Func}{"PureVirt"})
111020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became non-pure virtual
111030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Non_Pure"}{$tr_name{$Func}}}=(
111040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
111050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
111060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
111090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
111100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Level eq "Binary")
111110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # Binary-level
111121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        # check virtual table structure
111131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
111141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
111151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
111161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$AddedVFunc});
111171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $VPos_Added = $VirtualTable{2}{$CName}{$AddedVFunc};
111181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
111191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # pure virtual methods affect all others (virtual and non-virtual)
111201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$CName,
11122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
111231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
11124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(not defined $VirtualTable{1}{$CName}
11126dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            or $VPos_Added>keys(%{$VirtualTable{1}{$CName}}))
111271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # added virtual function at the end of v-table
111281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not keys(%{$VirtualTable_Model{1}{$CName}}))
111291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # became polymorphous class, added v-table pointer
111301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{"Added_First_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$CName,
11132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>get_Signature($AddedVFunc, 2)  );
111331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $VTableChanged_M{$CName} = 1;
11134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
111371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_Old = getVTable_Size($CName, 1);
111381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_New = getVTable_Size($CName, 2);
111399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next if($VSize_Old==$VSize_New); # exception: register as removed and added virtual method
111401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(isCopyingClass($Class_Id, 1))
111411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # class has no constructors and v-table will be copied by applications, this may affect all methods
111421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
111431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
111441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Copying_Class";
111451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
111461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
111471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
111481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    else
111521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
111531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
111541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
111551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Allocable_Class";
111561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
111571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
111581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
111591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
111601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
111611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
111621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
111631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
111651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
111661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
11167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName}
11168dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and defined $VirtualTable{2}{$CName})
111691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
11170dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11171dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11173dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Added<=$VPos_Old and $VPos_Old!=$VPos_New)
111741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11175dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11176dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11177dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11178850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11179850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
111809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11181850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11182850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11183dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11184dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11185dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{"Added_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11186dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11187dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($AddedVFunc, 2)  );
1118862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
111891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
111931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
111941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                # safe
111951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
111971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
111991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$RemovedVFunc});
112001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($RemovedVFunc eq $Interface
112011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
112021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # This case is for removed virtual methods
112039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # implemented in both versions of a library
112041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
112051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$VirtualTable_Model{2}{$CName}}))
112071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # became non-polymorphous class, removed v-table pointer
112081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Last_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
112111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
112121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
112141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
11215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11216dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName} and defined $VirtualTable{2}{$CName})
11217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11218dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(not defined $VirtualTable{1}{$CName}{$Interface}) {
11219dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        next;
11220dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11221dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = -1;
11222dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{2}{$CName}{$Interface})
112231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11224dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11225dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11226dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    else
11227dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11228dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if($Interface ne $RemovedVFunc) {
112291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
112301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11231dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11232dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Removed = $VirtualTable{1}{$CName}{$RemovedVFunc};
11233dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Removed<=$VPos_Old and $VPos_Old!=$VPos_New)
11235dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11237dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11238dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11239850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11240850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
112419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11242850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11243850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11244dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11245dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            my $ProblemType = "Removed_Virtual_Method";
11246dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"}) {
11247dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $ProblemType = "Removed_Pure_Virtual_Method";
11248dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11249dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11250dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$RemovedVFunc}}}=(
11251dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11252dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($RemovedVFunc, 1)  );
1125362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
112541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
112601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
112611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Source-level
112621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
112631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
112641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
112651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
112661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
112671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
112681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
112701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
112721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
112741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
11275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
112761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Pure_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
11279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byName($$)
11285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Name, $Pair_Type) = @_;
11287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Member_Name=~s/\A[_]+|[_]+\Z//g;
11288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos})
11291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Name = $Pair_Type->{"Memb"}{$MemberPair_Pos}{"name"};
11293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Name=~s/\A[_]+|[_]+\Z//g;
11294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name eq $Member_Name) {
11295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MemberPair_Pos;
11296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byVal($$)
11303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Value, $Pair_Type) = @_;
11305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos}
11308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Pair_Type->{"Memb"}{$MemberPair_Pos}{"value"} eq $Member_Value) {
11309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $MemberPair_Pos;
11310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub isRecurType($$$)
11316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach (@{$_[2]})
11318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1131962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if( $_->{"T1"} eq $_[0]
1132062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $_->{"T2"} eq $_[1] )
11321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub pushType($$$)
11329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my %IDs = (
113318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T1" => $_[0],
113328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T2" => $_[1]
113331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
113348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    push(@{$_[2]}, \%IDs);
11335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRenamed($$$$$)
11338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MemPos, $Type1, $LVersion1, $Type2, $LVersion2) = @_;
11340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Member_Name = $Type1->{"Memb"}{$MemPos}{"name"};
11341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemberType_Id = $Type1->{"Memb"}{$MemPos}{"type"};
11342f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %MemberType_Pure = get_PureType($MemberType_Id, $TypeInfo{$LVersion1});
11343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not defined $Type2->{"Memb"}{$MemPos}) {
11344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
11345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1134662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $PairType_Id = $Type2->{"Memb"}{$MemPos}{"type"};
11347f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{$LVersion2});
11348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1134962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Pair_Name = $Type2->{"Memb"}{$MemPos}{"name"};
1135062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MemberPair_Pos_Rev = ($Member_Name eq $Pair_Name)?$MemPos:find_MemberPair_Pos_byName($Pair_Name, $Type1);
11351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemberPair_Pos_Rev eq "lost")
11352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1135362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Name"} eq $PairType_Pure{"Name"})
1135462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # base type match
1135562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1135762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LVersion1}{$MemberType_Id}{"Name"} eq $TypeInfo{$LVersion2}{$PairType_Id}{"Name"})
1135862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # exact type match
1135962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1136162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Size"} eq $PairType_Pure{"Size"})
1136262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # size match
1136362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1136562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(isReserved($Pair_Name))
1136662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # reserved fields
1136762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
11371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLastElem($$)
11374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $TypeRef) = @_;
11376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $TypeRef->{"Memb"}{$Pos}{"name"};
11377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/last|count|max|total/i)
11378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GST_LEVEL_COUNT, GST_RTSP_ELAST
11379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/END|NLIMITS\Z/)
11382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # __RLIMIT_NLIMITS
11383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/\AN[A-Z](.+)[a-z]+s\Z/
11386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Pos+1==keys(%{$TypeRef->{"Memb"}}))
11387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # NImageFormats, NColorRoles
11388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub nonComparable($$)
11394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($T1, $T2) = @_;
11396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N1 = $T1->{"Name"};
11398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N2 = $T2->{"Name"};
11399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N1=~s/\A(struct|union|enum) //;
11401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N2=~s/\A(struct|union|enum) //;
11402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($N1 ne $N2
11404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N1)
11405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N2))
11406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different names
11407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} ne "Pointer"
11408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $T2->{"Type"} ne "Pointer")
11409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # compare base types
11410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11412fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($N1!~/\Avoid\s*\*/
11413fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $N2=~/\Avoid\s*\*/)
11414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($T1->{"Type"} ne $T2->{"Type"})
11419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
11420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} eq "Class"
11421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T2->{"Type"} eq "Struct")
11422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "struct"
11423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($T2->{"Type"} eq "Class"
11426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T1->{"Type"} eq "Struct")
11427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "struct" to "class"
11428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "enum"
11432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # "union" to "class"
11433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
11434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11440fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub isOpaque($)
11441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
11442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T = $_[0];
11443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not defined $T->{"Memb"})
11444fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
11446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
11448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removeVPtr($)
11451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{ # support for old ABI dumps
11452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $TPtr = $_[0];
11453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my @Pos = sort {int($a)<=>int($b)} keys(%{$TPtr->{"Memb"}});
11454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Pos>=1)
11455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Pos (0 .. $#Pos-1)
11457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$TPtr->{"Memb"}{$Pos}} = %{$TPtr->{"Memb"}{$Pos+1}};
11459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($TPtr->{"Memb"}{$#Pos});
11461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11464e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenkosub isPrivateABI($$)
11465e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko{
11466e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
11467e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11468e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    if($CheckPrivateABI) {
11469e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        return 0;
11470e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    }
11471e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11472e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$TypeId}{"PrivateABI"}) {
11473e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        return 1;
11474e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    }
11475e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11476e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    return 0;
11477e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko}
11478e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
1147962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub mergeTypes($$$)
11480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1148162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
11482f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Id or not $Type2_Id);
11483f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1148486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    if(defined $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id})
11485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already merged
11486f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id};
11487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11488f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1148962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1149062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
114911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Type1{"Name"} or not $Type2{"Name"}) {
11492f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
114931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
11494fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11495f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
11496f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
11497f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1149886b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"})
1149986b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    {
1150086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        if($Type1_Pure{"Name"} eq "__unknown__"
1150186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type2_Pure{"Name"} eq "__unknown__")
1150286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        { # Error ABI dump
1150386b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = {});
1150486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        }
1150586b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    }
1150686b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
11507e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    if(isPrivateABI($Type1_Id, 1)) {
11508e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko        return {};
11509e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    }
11510e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11511e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1{"Name"}} = 1;
11512e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1_Pure{"Name"}} = 1;
11513e3419b4a6666e1a56a0b3d34449f8bd0f73b11a9Andrey Ponomarenko
11514f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my %SubProblems = ();
11515f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11516fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
11517fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11518fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Type1_Pure{"Type"}=~/Struct|Union/
11519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $Type2_Pure{"Type"}=~/Struct|Union/)
11520fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11521fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(isOpaque(\%Type2_Pure) and not isOpaque(\%Type1_Pure))
11522fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
115231fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                if(not defined $UsedDump{1}{"DWARF"}
115241fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                and not defined $UsedDump{2}{"DWARF"})
115251fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                {
115261fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    %{$SubProblems{"Type_Became_Opaque"}{$Type1_Pure{"Name"}}}=(
115271fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        "Target"=>$Type1_Pure{"Name"},
115281fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
115291fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                }
11530fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11531f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11532fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11533fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11534fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11535fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Type1_Pure{"Size"}
11537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    or not $Type2_Pure{"Size"})
11538850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # including a case when "class Class { ... };" changed to "class Class;"
11539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $Type1_Pure{"Memb"} or not defined $Type2_Pure{"Memb"}
11540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or index($Type1_Pure{"Name"}, "<")==-1 or index($Type2_Pure{"Name"}, "<")==-1)
11541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # NOTE: template instances have no size
11542f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return {};
11543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
11544850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
115458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes))
11546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip recursive declarations
11547f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
11548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11549f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Pure{"Name"} or not $Type2_Pure{"Name"});
11550f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1_Pure{"Name"}});
11551f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1{"Name"}});
11552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
115531fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if(not isTargetType($Type1_Pure{"Tid"}, 1)) {
115541fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return {};
1155528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1155628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
11557fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Type"}=~/Class|Struct/ and $Type2_Pure{"Type"}=~/Class|Struct/)
11558fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
11559fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      # _vptr field added in 3.0
11560fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not checkDump(1, "3.0") and checkDump(2, "3.0"))
11561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type2_Pure{"Memb"}
11563fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type2_Pure{"Memb"}{0}{"name"} eq "_vptr")
11564fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type2_Pure{"Memb"}})==1) {
11566fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type2_Pure{"Memb"}{0});
11567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type2_Pure);
11570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11571fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11572fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11573fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(checkDump(1, "3.0") and not checkDump(2, "3.0"))
11574fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11575fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type1_Pure{"Memb"}
11576fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type1_Pure{"Memb"}{0}{"name"} eq "_vptr")
11577fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11578fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type1_Pure{"Memb"}})==1) {
11579fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type1_Pure{"Memb"}{0});
11580fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11581fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type1_Pure);
11583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11586fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1158862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
1158962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
11590fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
115916ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    if(%Typedef_1 and %Typedef_2
11592dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef"
11593dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Name"} eq $Typedef_2{"Name"})
11594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11595f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_1 = get_OneStep_BaseType($Typedef_1{"Tid"}, $TypeInfo{1});
11596f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_2 = get_OneStep_BaseType($Typedef_2{"Tid"}, $TypeInfo{2});
11597850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base_1{"Name"} ne $Base_2{"Name"})
11598850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
11599850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(differentDumps("G")
11600850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or differentDumps("V"))
11601850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # different GCC versions or different dumps
11602850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"} = uncover_typedefs($Base_1{"Name"}, 1);
11603850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"} = uncover_typedefs($Base_2{"Name"}, 2);
11604850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # std::__va_list and __va_list
11605850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"}=~s/\A(\w+::)+//;
11606850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"}=~s/\A(\w+::)+//;
116079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_1{"Name"} = formatName($Base_1{"Name"}, "T");
116089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_2{"Name"} = formatName($Base_2{"Name"}, "T");
11609850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
11610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Base_1{"Name"}!~/anon\-/ and $Base_2{"Name"}!~/anon\-/
11612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Base_1{"Name"} ne $Base_2{"Name"})
11613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
116141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
11615d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            and $Type1{"Size"} and $Type2{"Size"}
116161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Type1{"Size"} ne $Type2{"Size"})
11617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"DataType_Size"}{$Typedef_1{"Name"}}}=(
11619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Typedef_1{"Name"},
11620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Typedef_1{"Name"},
11621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
11622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE  );
11623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
116248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base1_Pure = get_PureType($Base_1{"Tid"}, $TypeInfo{1});
116258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base2_Pure = get_PureType($Base_2{"Tid"}, $TypeInfo{2});
1162686b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
1162786b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            if(defined $UsedDump{1}{"DWARF"})
1162886b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            {
1162986b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                if($Base1_Pure{"Name"}=~/\b__unknown__\b/
1163086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                or $Base2_Pure{"Name"}=~/\b__unknown__\b/)
1163186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                { # Error ABI dump
1163286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = {});
1163386b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko                }
1163486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            }
1163586b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
11636fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(tNameLock($Base_1{"Tid"}, $Base_2{"Tid"}))
116378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
11638fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(diffTypes($Base1_Pure{"Tid"}, $Base2_Pure{"Tid"}, $Level))
11639fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11640fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType_Format"}{$Typedef_1{"Name"}}}=(
11641fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11642fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11643fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11644fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11645fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
11647fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11648fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType"}{$Typedef_1{"Name"}}}=(
11649fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11650fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
116548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
11655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(nonComparable(\%Type1_Pure, \%Type2_Pure))
11658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types (reported in detectTypeChange(...))
1165974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT1 = $Type1_Pure{"Type"};
1166074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT2 = $Type2_Pure{"Type"};
1166174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1166274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($TT1 ne $TT2
1166374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        and $TT1!~/Intrinsic|Pointer|Ref|Typedef/)
11664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different type of the type
1166574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short1 = $Type1_Pure{"Name"};
1166674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short2 = $Type2_Pure{"Name"};
1166774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1166874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short1=~s/\A\Q$TT1\E //ig;
1166974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short2=~s/\A\Q$TT2\E //ig;
1167074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1167174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($Short1 eq $Short2)
1167274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1167374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                %{$SubProblems{"DataType_Type"}{$Type1_Pure{"Name"}}}=(
1167474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
1167574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
1167674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Old_Value"=>lc($Type1_Pure{"Type"}),
1167774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>lc($Type2_Pure{"Type"})  );
1167874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
11679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11680f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
116829e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
116838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes);
116849e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
11685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}
11686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or (isAnon($Type1_Pure{"Name"}) and isAnon($Type2_Pure{"Name"})))
11687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking size
116891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
11690d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        and $Type1_Pure{"Size"} and $Type2_Pure{"Size"}
116911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ProblemKind = "DataType_Size";
11694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Class"
116951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$ClassMethods{$Level}{1}{$Type1_Pure{"Name"}}}))
11696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isCopyingClass($Type1_Pure{"Tid"}, 1)) {
11698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemKind = "Size_Of_Copying_Class";
11699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($AllocableClass{1}{$Type1_Pure{"Name"}})
11701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(int($Type2_Pure{"Size"})>int($Type1_Pure{"Size"})) {
11703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemKind = "Size_Of_Allocable_Class_Increased";
11704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11705fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    else
11706fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
11707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # descreased size of allocable class
11708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # it has no special effects
11709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$SubProblems{$ProblemKind}{$Type1_Pure{"Name"}}}=(
11713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Type1_Pure{"Name"},
11714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Type_Name"=>$Type1_Pure{"Name"},
11715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Size"=>$Type1_Pure{"Size"}*$BYTE_SIZE,
11716f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "New_Size"=>$Type2_Pure{"Size"}*$BYTE_SIZE);
11717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Type1_Pure{"BaseType"}
11720fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and defined $Type2_Pure{"BaseType"})
117210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # checking base types
11722f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Sub_SubProblems = mergeTypes($Type1_Pure{"BaseType"}, $Type2_Pure{"BaseType"}, $Level);
11723f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
11724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11725f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}})) {
11726f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
11727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%AddedField, %RemovedField, %RenamedField, %RenamedField_Rev, %RelatedField, %RelatedField_Rev) = ();
11731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosA = map {$Type1_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type1_Pure{"Memb"}});
11732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosB = map {$Type2_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type2_Pure{"Memb"}});
11733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect removed and renamed fields
11735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isUnnamed($Member_Name))
11743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # support for old-version dumps
11744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1174562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(not checkDump(2, "2.1")) {
11746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $RenamedTo = isRenamed($Member_Pos, \%Type1_Pure, 1, \%Type2_Pure, 2))
11750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11751082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField{$Member_Pos} = $RenamedTo;
11752082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11756082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MemberPair_Pos = find_MemberPair_Pos_byVal($Member_Value1, \%Type2_Pure);
11764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberPair_Pos ne "lost")
11765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $RenamedTo = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"name"};
11767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $MemberPair_Pos_Rev = find_MemberPair_Pos_byName($RenamedTo, \%Type1_Pure);
11768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberPair_Pos_Rev eq "lost")
11769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
11770082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField{$Member_Pos} = $RenamedTo;
11771082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else {
11774082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RemovedField{$Member_Pos} = 1;
11775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11779082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # related
11785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField{$Member_Pos} = $MemberPair_Pos;
11786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField_Rev{$MemberPair_Pos} = $Member_Pos;
11787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added fields
11791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isUnnamed($Member_Name))
11797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old-version dumps
117981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1179962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not checkDump(1, "2.1")) {
11800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union|Enum)\Z/)
11804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $RenamedField_Rev{$Member_Pos})
11806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added
11807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $AddedField{$Member_Pos}=1;
11808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect moved fields
11814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (%RelPos, %RelPosName, %AbsPos) = ();
11815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
11816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 1st version
11818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $RemovedField{$Member_Pos})
11821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # old type without removed fields
11822082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{1}{$Member_Name} = $Pos;
11823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{1}{$Pos} = $Member_Name;
11824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{1}{$Pos++} = $Member_Pos;
11825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Pos = 0;
11828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 2nd version
11830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $AddedField{$Member_Pos})
11833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # new type without added fields
11834082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{2}{$Member_Name} = $Pos;
11835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{2}{$Pos} = $Member_Name;
11836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{2}{$Pos++} = $Member_Pos;
11837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Name (keys(%{$RelPos{1}}))
11840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos1 = $RelPos{1}{$Member_Name};
11842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $AbsPos1 = $NameToPosA{$Member_Name};
11843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name2 = $Member_Name;
11844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $RenamedTo = $RenamedField{$AbsPos1})
11845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # renamed
11846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Member_Name2 = $RenamedTo;
11847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos2 = $RelPos{2}{$Member_Name2};
11849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RPos2 ne "" and $RPos1 ne $RPos2)
11850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different relative positions
11851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $AbsPos2 = $NameToPosB{$Member_Name2};
11852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($AbsPos1 ne $AbsPos2)
11853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # different absolute positions
11854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Moved_Field";
11855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not isPublic(\%Type1_Pure, $AbsPos1))
11856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # may change layout and size of type
118571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Source") {
118581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
118591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Moved_Private_Field";
11861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
118621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Binary"
118631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
1186562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize1 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$AbsPos1}{"type"}}{"Size"};
11866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $MovedAbsPos = $AbsPos{1}{$RPos2};
1186762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize2 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$MovedAbsPos}{"type"}}{"Size"};
11868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($MemSize1 ne $MemSize2) {
11869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Size";
11870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Moved_Private_Field") {
11873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$RPos1,
11879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RPos2 );
11880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
118851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check older fields, public and private
11886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11888082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
11889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RenamedTo = $RenamedField{$Member_Pos})
11890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # renamed
118918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Constants{2}{$Member_Name})
118928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
118938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Constants{2}{$Member_Name}{"Value"} eq $RenamedTo)
118948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # define OLD NEW
118958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next; # Safe
118968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
118978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
118988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
11899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isPublic(\%Type1_Pure, $Member_Pos))
11902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Renamed_Field"}{$Member_Name}}=(
11904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
11907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
11908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(isReserved($Member_Name))
119109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
119119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    %{$SubProblems{"Used_Reserved_Field"}{$Member_Name}}=(
119129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Target"=>$Member_Name,
119139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
119149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
119159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
119169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
11917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Name"}{$Type1_Pure{"Memb"}{$Member_Pos}{"value"}}}=(
11921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Memb"}{$Member_Pos}{"value"},
11922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name,
11924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$RenamedTo  );
11925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RemovedField{$Member_Pos})
11928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # removed
11929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Removed_Field";
11932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos)
119331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
119341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
119351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
119361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
119371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
11938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Removed_Private_Field";
11939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected fields
11945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
11947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
11948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
11952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
11953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Removed_Private_Field") {
11956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
11959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1196074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
11963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
119641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
119651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field_And_Size"}{$Member_Name}}=(
11968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1196974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field"}{$Member_Name}}=(
11974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1197574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Removed"}{$Member_Name}}=(
11981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
11982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name  );
11984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # changed
11988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $MemberPair_Pos = $RelatedField{$Member_Pos};
11989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Enum")
11990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"value"};
11994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value2 eq "");
11995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Member_Value1 ne $Member_Value2)
11996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Enum_Member_Value";
11998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isLastElem($Member_Pos, \%Type1_Pure)) {
11999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Enum_Last_Member_Value";
12000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($SkipConstants{1}{$Member_Name}) {
12002fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemType = "Enum_Private_Member_Value";
12003fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
12006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
12007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Value1,
12008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Member_Value2  );
12009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
12012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12013fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access1 = $Type1_Pure{"Memb"}{$Member_Pos}{"access"};
12014fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"access"};
12015fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12016fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Access1 ne "private"
12017fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "private")
12018fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12019fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Private"}{$Member_Name}}=(
12020fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12021fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12022fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12023fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Access1 ne "protected"
12024fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access1 ne "private"
12025fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "protected")
12026fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Protected"}{$Member_Name}}=(
12028fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType1_Id = $Type1_Pure{"Memb"}{$Member_Pos}{"type"};
12033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType2_Id = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"type"};
1203462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV1 = $TypeInfo{1}{$MemberType1_Id}{"Size"}*$BYTE_SIZE;
12035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize1 = $Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}) {
12036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV1 = $BSize1;
12037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1203862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV2 = $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE;
12039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}) {
12040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV2 = $BSize2;
12041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1204262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType1_Name = $TypeInfo{1}{$MemberType1_Id}{"Name"};
1204362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType2_Name = $TypeInfo{2}{$MemberType2_Id}{"Name"};
120441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12045d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                and $SizeV1 and $SizeV2
120461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $SizeV1 ne $SizeV2)
12047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberType1_Name eq $MemberType2_Name or (isAnon($MemberType1_Name) and isAnon($MemberType2_Name))
12049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"} and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}))
12050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # field size change (including anon-structures and unions)
12051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - same types
12052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - unnamed types
12053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - bitfields
12054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Field_Size";
12055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name))
12057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # should not be accessed by applications, goes to "Low Severity"
12058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                          # example: "abidata" members in GStreamer types
12059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12061fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12063fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12064fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12066fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType eq "Private_Field_Size")
12076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # private field size with no effect
12077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1207846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($ProblemType eq "Field_Size")
1207946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        {
1208046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            if($Type1_Pure{"Type"}=~/Union|Struct/ and $SizeV1<$SizeV2)
1208146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            { # Low severity
1208246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                                $ProblemType = "Struct_Field_Size_Increased";
1208346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            }
1208446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
12085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType)
12086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # register a problem
12087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            %{$SubProblems{$ProblemType}{$Member_Name}}=(
12088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Target"=>$Member_Name,
12089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Type_Name"=>$Type1_Pure{"Name"},
12090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Old_Size"=>$SizeV1,
12091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "New_Size"=>$SizeV2);
12092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}
12096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"})
12097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check bitfield type changes
12098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1210062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(checkDump(1, "2.13") and checkDump(2, "2.13"))
121010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
121020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not $Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
121030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
121040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
121050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Mutable"}{$Member_Name}}=(
121060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1210774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
121080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    elsif($Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
121100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and not $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
121110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
12112fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Non_Mutable"}{$Member_Name}}=(
121130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1211474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
121150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
12117f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my %Sub_SubChanges = detectTypeChange($MemberType1_Id, $MemberType2_Id, "Field", $Level);
12118f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12120f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12121f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12122fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    # quals
12124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type"
12125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_And_Size"
12126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_Format")
12127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1212862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(checkDump(1, "2.6") and checkDump(2, "2.6"))
12129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(addedQual($Old_Value, $New_Value, "volatile")) {
12131f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
121320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12133fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            elsif(removedQual($Old_Value, $New_Value, "volatile")) {
12134f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
12135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
121370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(my $RA = addedQual($Old_Value, $New_Value, "const"))
121380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RA==2) {
12140f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Added_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12143f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
121460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
121470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RR==2) {
12149f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Removed_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12152f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
12155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Source")
12159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12160f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $ProblemType (keys(%Sub_SubChanges))
12161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
12162f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12163f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12164fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($ProblemType eq "Field_Type")
12166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
12167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
12168f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                delete($Sub_SubChanges{$ProblemType});
121690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
12171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12174f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType_Init = $ProblemType;
12177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type_And_Size")
121781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # Binary
12179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12183fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12185fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12186fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12188fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
12199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12200d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        # TODO: Private_Field_Type rule?
12201d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
12202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
12205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Private_Field_Type_And_Size")
12208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # private field change with no effect
12209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1221274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
1221374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
12214f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Attr (keys(%{$Sub_SubChanges{$ProblemType_Init}}))
12215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # other properties
12216f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $SubProblems{$ProblemType}{$Member_Name}{$Attr} = $Sub_SubChanges{$ProblemType_Init}{$Attr};
12217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos))
12220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check internal type changes
12221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberType1_Id and $MemberType2_Id)
12224f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # checking member type changes
12225f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Sub_SubProblems = mergeTypes($MemberType1_Id, $MemberType2_Id, $Level);
12226f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12227f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my %DupProblems = ();
12228f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12229f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
12230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12231f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}}))
12232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12233f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12234f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12235f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                if(defined $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}}) {
12236f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    next;
12237f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                }
12238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12239f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12240f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $NewLocation = ($Sub_SubLocation)?$Member_Name."->".$Sub_SubLocation:$Member_Name;
12241f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            $SubProblems{$Sub_SubProblemType}{$NewLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
12242f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12243f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12245f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}} = 1;
12246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12249f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12250f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %DupProblems = ();
12251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
12256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added members, public and private
12257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
12258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
12259082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
12260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AddedField{$Member_Pos})
12261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # added
12262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
12263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Added_Field";
12265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type2_Pure, $Member_Pos)
122661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
122671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
122681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
122691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
122701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Added_Private_Field";
12272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
122731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type2_Pure, \%AddedField, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type2_Pure, \%AddedField, $Member_Pos, -1))
12277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # public fields after the current
12278fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
12280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
12281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
12285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Added_Private_Field")
12288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # skip added private fields
12289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
12292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1229374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"});
12294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
12296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
122971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
122981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
12299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field_And_Size"}{$Member_Name}}=(
12301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1230274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field"}{$Member_Name}}=(
12307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1230874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Enum")
12312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value = $Type2_Pure{"Memb"}{$Member_Pos}{"value"};
12314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value eq "");
12315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Added_Enum_Member"}{$Member_Name}}=(
12316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type2_Pure{"Name"},
1231874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>$Member_Value);
12319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12322f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
123238a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    if($Type1_Pure{"Type"} eq "FuncPtr")
123248a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    {
123258a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        foreach my $PPos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Param"}}))
123268a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        {
123278a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if(not defined $Type2_Pure{"Param"}{$PPos}) {
123288a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                next;
123298a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
123308a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123318a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $PT1 = $Type1_Pure{"Param"}{$PPos}{"type"};
123328a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $PT2 = $Type2_Pure{"Param"}{$PPos}{"type"};
123338a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123348a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $PName = "p".$PPos;
123358a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123368a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $FP_SubProblems = mergeTypes($PT1, $PT2, $Level);
123378a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my %DupProblems = ();
123388a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123398a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            foreach my $FP_SubProblemType (keys(%{$FP_SubProblems}))
123408a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            {
123418a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                foreach my $FP_SubLocation (keys(%{$FP_SubProblems->{$FP_SubProblemType}}))
123428a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                {
123438a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    if(not defined $AllAffected)
123448a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    {
123458a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                        if(defined $DupProblems{$FP_SubProblems->{$FP_SubProblemType}{$FP_SubLocation}}) {
123468a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                            next;
123478a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                        }
123488a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    }
123498a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123508a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    my $NewLocation = ($FP_SubLocation)?$PName."->".$FP_SubLocation:$PName;
123518a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    $SubProblems{$FP_SubProblemType}{$NewLocation} = $FP_SubProblems->{$FP_SubProblemType}{$FP_SubLocation};
123528a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123538a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    if(not defined $AllAffected)
123548a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    {
123558a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                        $DupProblems{$FP_SubProblems->{$FP_SubProblemType}{$FP_SubLocation}} = 1;
123568a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    }
123578a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                }
123588a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
123598a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
123608a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            %DupProblems = ();
123618a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
123628a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    }
123638a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
12364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurTypes);
12365f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
12366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isUnnamed($) {
12369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0]=~/\Aunnamed\d+\Z/;
12370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1237274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_ShortClass($$)
12373dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{
12374dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1237574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TypeName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
1237674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeInfo{$LibVersion}{$TypeId}{"Type"}!~/Intrinsic|Class|Struct|Union|Enum/) {
1237774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName = uncover_typedefs($TypeName, $LibVersion);
1237874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1237962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $NameSpace = $TypeInfo{$LibVersion}{$TypeId}{"NameSpace"}) {
1238074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName=~s/\A(struct |)\Q$NameSpace\E\:\://g;
12381dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
12382dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $TypeName;
12383dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
12384dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1238562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub goToFirst($$$)
12386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1238762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion, $Type_Type) = @_;
123881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return () if(not $TypeId);
1238962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}) {
1239062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}};
12391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1239262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1239362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type{"Type"});
12395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} ne $Type_Type)
12396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return () if(not $Type{"BaseType"});
12398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = goToFirst($Type{"BaseType"}, $LibVersion, $Type_Type);
12399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1240062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type} = \%Type;
12401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TypeSpecAttributes = (
12405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Const" => 1,
12406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Volatile" => 1,
12407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ConstVolatile" => 1,
12408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Restrict" => 1,
12409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Typedef" => 1
12410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
12411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1241262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PureType($$)
12413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12414f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12415f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12416f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12417f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12419f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(defined $Cache{"get_PureType"}{$TypeId}{$Info}) {
12420f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %{$Cache{"get_PureType"}{$TypeId}{$Info}};
12421f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12422f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeSpecAttributes{$Type{"Type"}}) {
12425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = get_PureType($Type{"BaseType"}, $Info);
12426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12427f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $Cache{"get_PureType"}{$TypeId}{$Info} = \%Type;
12428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1243162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PLevel($$)
12432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1243362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypeId);
1243562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_PLevel"}{$TypeId}{$LibVersion}) {
1243662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_PLevel"}{$TypeId}{$LibVersion};
12437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1243862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $TypeInfo{$LibVersion}{$TypeId});
1243962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12440fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 1 if($Type{"Type"}=~/FuncPtr|FieldPtr/);
12441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $PLevel = 0;
12442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type{"Type"} =~/Pointer|Ref|FuncPtr|FieldPtr/) {
12443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $PLevel += 1;
12444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel if(not $Type{"BaseType"});
12446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $PLevel += get_PLevel($Type{"BaseType"}, $LibVersion);
12447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $Cache{"get_PLevel"}{$TypeId}{$LibVersion} = $PLevel;
12448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel;
12449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1245162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseType($$)
12452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1245362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $TypeId);
1245562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_BaseType"}{$TypeId}{$LibVersion}) {
1245662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"get_BaseType"}{$TypeId}{$LibVersion}};
12457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1245862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1245962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    %Type = get_BaseType($Type{"BaseType"}, $LibVersion);
1246262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"get_BaseType"}{$TypeId}{$LibVersion} = \%Type;
12463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1246662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseTypeQual($$)
12467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1246862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeId);
1247062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $TypeInfo{$LibVersion}{$TypeId});
1247162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return "" if(not $Type{"BaseType"});
12473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Qual = "";
12474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} eq "Pointer") {
12475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "*";
12476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Ref") {
12478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "&";
12479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "ConstVolatile") {
12481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "const volatile";
12482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Const"
12484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Volatile"
12485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Restrict") {
12486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= lc($Type{"Type"});
12487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $BQual = get_BaseTypeQual($Type{"BaseType"}, $LibVersion);
12489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $BQual.$Qual;
12490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1249262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_OneStep_BaseType($$)
12493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12494f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12495f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12496f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12497f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12498f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12499f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12501fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(my $BTid = $Type{"BaseType"})
12502f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
12503f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Info->{$BTid}) {
12504f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return %{$Info->{$BTid}};
12505f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12506f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else { # something is going wrong
12507f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return ();
12508f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12509f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12510f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    else {
12511f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %Type;
12512f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1251562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_Type($$)
12516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1251762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12518dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return () if(not $TypeId);
1251962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1252062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return %{$TypeInfo{$LibVersion}{$TypeId}};
12521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12523989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub isPrivateData($)
125240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{ # non-public global data
12525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
12526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Symbol=~/\A(_ZGV|_ZTI|_ZTS|_ZTT|_ZTV|_ZTC|_ZThn|_ZTv0_n)/);
12527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12529ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isInLineInst($$) {
1253001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return (isTemplateInstance(@_) and not isTemplateSpec(@_));
1253101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1253201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
12533ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateInstance($$)
12534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12535ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
12536ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12537ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
1253862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12539ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"})
1254062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
12541ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(index($ClassName,"<")!=-1) {
12542ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 1;
1254362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1254462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1254562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12546ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ShortName = $SInfo->{"ShortName"})
1254762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12548ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(index($ShortName,"<")!=-1
12549ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        and index($ShortName,">")!=-1) {
12550ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            return 1;
1255162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1255262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12553ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1255462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
12555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12557ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateSpec($$)
12558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12559ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
1256001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
12561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1256262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$ClassId}{"Spec"})
12563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class specialization
12564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1256601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        elsif($SInfo->{"Spec"})
12567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # method specialization
12568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
12572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub symbolFilter($$$$)
12575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # some special cases when the symbol cannot be imported
125761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $LibVersion, $Type, $Level) = @_;
12577ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12578989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isPrivateData($Symbol))
12579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # non-public global data
12580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
12581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12582d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
125831fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if(defined $SkipInternalSymbols)
12584d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
125851fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return 0 if($Symbol=~/($SkipInternalSymbols)/);
12586d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
12587d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1258828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($Symbol=~/\A_Z/)
1258928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    {
1259028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Symbol=~/[CD][3-4]E/) {
1259128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
1259228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1259328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1259428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1259562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckHeadersOnly and not checkDump($LibVersion, "2.7"))
12596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps in --headers-only mode
12597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Pos (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
12598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Pid = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"})
12600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1260162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType = $TypeInfo{$LibVersion}{$Pid}{"Type"};
12602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $PType or $PType eq "Unknown") {
12603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12608850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type=~/Affected/)
12609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12610ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my $Header = $CompleteSignature{$LibVersion}{$Symbol}{"Header"};
12611ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipSymbols{$LibVersion}{$Symbol})
12613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols to ignore
12614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12616ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12617ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($SymbolsListPath and not $SymbolsList{$Symbol})
12618ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols
12619ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not $TargetHeadersPath or not $Header
12620ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or not is_target_header($Header, 1))
12621ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # -symbols-list | -headers-list
12622ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 0;
12623ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
12624ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12625ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12626ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($AppPath and not $SymbolsList_App{$Symbol})
12627ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols (in application)
12628ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            return 0;
12629ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12630ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12631ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"};
12632ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
126331fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        if($ClassId)
126341fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        {
126351fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            if(not isTargetType($ClassId, $LibVersion)) {
126361fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                return 0;
126371fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            }
126381fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        }
126391fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
12640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
12641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $NameSpace and $ClassId)
12642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class methods have no "NameSpace" attribute
1264362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $NameSpace = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"};
12644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($NameSpace)
12646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined namespaces to ignore
12647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SkipNameSpaces{$LibVersion}{$NameSpace}) {
12648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
12649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NS (keys(%{$SkipNameSpaces{$LibVersion}}))
12651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nested namespaces
12652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NameSpace=~/\A\Q$NS\E(\:\:|\Z)/) {
12653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12657ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Header)
12658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1265962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Skip = skipHeader($Header, $LibVersion))
12660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # --skip-headers or <skip_headers> (not <skip_including>)
12661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip==1) {
12662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12666ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($TypesListPath and $ClassId)
1266752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        { # user defined types
1266852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1266952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1267052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if(not $TypesList{$CName})
1267152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
12672ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(my $NS = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"})
12673ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12674ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    $CName=~s/\A\Q$NS\E\:\://g;
12675ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
12676ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12677ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(not $TypesList{$CName})
12678ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12679ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    my $Found = 0;
12680ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12681ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    while($CName=~s/\:\:.+?\Z//)
12682ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    {
12683ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        if($TypesList{$CName})
12684ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        {
12685ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            $Found = 1;
12686ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            last;
12687ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        }
12688ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12689ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12690ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    if(not $Found) {
12691ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        return 0;
12692ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12693ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
1269452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1269552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
12696ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $Level, $LibVersion))
12698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
12699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 0;
12700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
127011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
12702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12703ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
12704ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($CompleteSignature{$LibVersion}{$Symbol}, $LibVersion))
127051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
12706ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                if($ClassId and $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
12707ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline virtual methods
12708ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if($Type=~/InlineVirt/) {
12709ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        return 1;
12710ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    }
12711ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    my $Allocable = (not isCopyingClass($ClassId, $LibVersion));
12712ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable)
12713ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    { # check bases
12714ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        foreach my $DCId (get_sub_classes($ClassId, $LibVersion, 1))
12715ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        {
12716ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            if(not isCopyingClass($DCId, $LibVersion))
12717ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            { # exists a derived class without default c-tor
12718ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                $Allocable=1;
12719ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                last;
127201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
12721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12723ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable) {
127241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        return 0;
127251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12727ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                else
12728ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline non-virtual methods
12729ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    return 0;
12730ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                }
12731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
12735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded($)
12738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{2}}))
12741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 1, "+Deps"))
12743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find a new symbol
12744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the old-version library
12745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # So, it's not a new symbol
12746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{2}{$Symbol}
1274962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $AddedInt{$Level}{$Symbol} = 1;
12753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved($)
12757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{1}}))
12760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 2, "+Deps"))
12762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find an old symbol
12763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the new-version library
12764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{1}{$Symbol}
1276762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RemovedInt{$Level}{$Symbol} = 1;
12771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeLibs($)
12775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
127771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
12780ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{2}{$Symbol}{"Header"});
12781c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected + InlineVirt", $Level));
127821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
127841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
12787ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Symbol}{"Header"});
127889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_ZTV")==0)
12789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip v-tables for templates, that should not be imported by applications
12790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($tr_name{$Symbol}=~/</);
12791dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $CName = $VTableClass{$Symbol})
12792dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12793dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(not keys(%{$ClassMethods{$Level}{1}{$CName}}))
12794dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # vtables for "private" classes
127950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # use case: vtable for QDragManager (Qt 4.5.3 to 4.6.0) became HIDDEN symbol
12796dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    next;
12797dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
12798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
127998a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
128008a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if($SkipSymbols{1}{$Symbol})
128018a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            { # user defined symbols to ignore
128028a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                next;
128038a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
12804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12806c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko            next if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level));
12807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"})
12809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # symbols for pure virtual methods cannot be called by clients
12810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1281662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub checkDump($$)
128171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
1281862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($LibVersion, $V) = @_;
1281962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"checkDump"}{$LibVersion}{$V}) {
1282062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"checkDump"}{$LibVersion}{$V};
1282162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1282262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"checkDump"}{$LibVersion}{$V} = (not $UsedDump{$LibVersion}{"V"} or cmpVersions($UsedDump{$LibVersion}{"V"}, $V)>=0));
128231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
128241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
128251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded_H($)
12826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{2}}))
12829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
128301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
128311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
128321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
128331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
12834b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
12835b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"Artificial"})
12836b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            { # skip artificial constructors
12837b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                next;
12838b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
128391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}
128411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"}) {
128421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
128431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1284462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
128481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"})
128491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
128501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{2}{"SrcBin"})
128511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
1285262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{1}{"BinOnly"} or not checkDump(1, "2.11"))
128531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # support for old and different (!) ABI dumps
128541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{2}{$Symbol}{"Virt"}
128551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{2}{$Symbol}{"PureVirt"})
128561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
128571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
12858850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        {
12859850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{2}{$Symbol}{"Lang"})
12860850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12861850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12862850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12864850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12865850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
128661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
128671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
128681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
128691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 2, "-Deps"))
128700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            { # skip added inline symbols and const global data
128711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
128721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
128731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
128741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
128751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
128761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
128771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedInt{$Level}{$Symbol} = 1;
12878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
128821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved_H($)
12883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
12886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
128871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
128881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
128891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
128901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
128911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
128931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"}) {
128941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
128951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1289662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{2}{$Symbol}
129001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"})
12901850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
129021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{1}{"SrcBin"})
129031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1290462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{2}{"BinOnly"} or not checkDump(2, "2.11"))
12905850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # support for old and different (!) ABI dumps
129061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{1}{$Symbol}{"Virt"}
129071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{1}{$Symbol}{"PureVirt"})
129081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
129101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # skip all removed symbols
12911850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{1}{$Symbol}{"Lang"})
12912850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12913850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12914850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12915850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12916850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12917850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
129181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
129201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
129211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 1, "-Deps"))
129221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            { # skip removed inline symbols
129231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
129241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
129251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
129281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12929b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not checkDump(1, "2.15"))
12930b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            {
12931b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                if($Symbol=~/_IT_E\Z/)
12932b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                { # _ZN28QExplicitlySharedDataPointerI22QSslCertificatePrivateEC1IT_EERKS_IT_E
12933b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                    next;
12934b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                }
12935b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
129369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Class"})
129379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
129389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Short = $CompleteSignature{1}{$Symbol}{"ShortName"})
129399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
129409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(defined $Constants{2}{$Short})
129419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
129429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        my $Val = $Constants{2}{$Short}{"Value"};
129439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(defined $Func_ShortName{2}{$Val})
129449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # old name defined to new
129459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
129469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
129479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
129489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
129499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
129509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
129511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RemovedInt{$Level}{$Symbol} = 1;
129521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
129531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # search for a source-compatible equivalent
129541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                setAlternative($Symbol, $Level);
129551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeHeaders($)
12961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
129631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"PureVirt"});
129669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
129679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected", $Level));
12968850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12969850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12970850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"InLine"})
12971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12972850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{2}{$Symbol}{"Virt"})
12973850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12974850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12975850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12976850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
129771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
129791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
129801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($SourceAlternative_B{$Symbol}) {
129811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
129821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
129831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
129861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"PureVirt"});
129899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
129909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 1, "Affected", $Level));
12991850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12992850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12993850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"InLine"})
12994850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12995850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{1}{$Symbol}{"Virt"})
12996850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12997850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12998850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12999850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
130001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
130021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
130030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Alt = $SourceAlternative{$Symbol})
130040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Alt}
130060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"Const"})
130070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
1300862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
13009f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Removed_Const_Overload"}{"this"}}=(
1301062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Type_Name"=>$TypeInfo{1}{$Cid}{"Name"},
1301174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Target"=>get_Signature($Alt, 1));
130120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                else
130140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # do NOT show removed symbol
130150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    next;
130160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
13020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addParamNames($)
13024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibraryVersion = $_[0];
13026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not keys(%AddIntParams));
13027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SecondVersion = $LibraryVersion==1?2:1;
13028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompleteSignature{$LibraryVersion}}))
13029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not keys(%{$AddIntParams{$Interface}}));
13031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibraryVersion}{$Interface}{"Param"}}))
13032850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # add absent parameter names
13033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamName = $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"};
13034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamName=~/\Ap\d+\Z/ and my $NewParamName = $AddIntParams{$Interface}{$ParamPos})
13035850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # names from the external file
13036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(defined $CompleteSignature{$SecondVersion}{$Interface}
13037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and defined $CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos})
13038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos}{"name"}=~/\Ap\d+\Z/) {
13040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectChangedTypedefs()
13052989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # detect changed typedefs to show
13053989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  # correct function signatures
13054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Typedef (keys(%{$Typedef_BaseName{1}}))
13055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Typedef);
13057989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName1 = $Typedef_BaseName{1}{$Typedef};
13058989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName1 or isAnon($BName1)) {
13059989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13060989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13061989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName2 = $Typedef_BaseName{2}{$Typedef};
13062989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName2 or isAnon($BName2)) {
13063989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13064989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13065989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($BName1 ne $BName2) {
13066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedTypedef{$Typedef} = 1;
13067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_suffix($$)
13072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
130731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $Full) = @_;
130741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($SN, $SO, $SV) = separate_symbol($Symbol);
13075570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Symbol=$SN; # remove version
130761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Signature = $tr_name{$Symbol};
130771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Suffix = substr($Signature, find_center($Signature, "("));
13078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Full) {
13079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Suffix=~s/(\))\s*(const volatile|volatile const|const|volatile)\Z/$1/g;
13080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Suffix;
13082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_prefix($$)
13085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
13087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
13088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
13089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # methods
1309062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $ShortName = $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::".$ShortName;
13091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ShortName;
13093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
130951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub setAlternative($)
130961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
130971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Symbol = $_[0];
130981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $PSymbol = $Symbol;
130991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not defined $CompleteSignature{2}{$PSymbol}
131001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or (not $CompleteSignature{2}{$PSymbol}{"MnglName"}
131011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and not $CompleteSignature{2}{$PSymbol}{"ShortName"}))
131021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for a pair
13103dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $ShortName = $CompleteSignature{1}{$PSymbol}{"ShortName"})
131041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
13105dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($CompleteSignature{1}{$PSymbol}{"Data"})
131061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
13107dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($PSymbol=~s/L(\d+$ShortName(E)\Z)/$1/
13108dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or $PSymbol=~s/(\d+$ShortName(E)\Z)/L$1/)
131091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
131101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$PSymbol}
131111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $CompleteSignature{2}{$PSymbol}{"MnglName"})
131121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
131131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative{$Symbol} = $PSymbol;
131141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative_B{$PSymbol} = $Symbol;
131151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not defined $CompleteSignature{1}{$PSymbol}
131161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
131171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SourceReplacement{$Symbol} = $PSymbol;
131181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
131191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
131201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
13121dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
13122dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else
13123dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
13124dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                foreach my $Sp ("KV", "VK", "K", "V")
13125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
13126dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($PSymbol=~s/\A_ZN$Sp/_ZN/
13127dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    or $PSymbol=~s/\A_ZN/_ZN$Sp/)
13128dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
13129dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if(defined $CompleteSignature{2}{$PSymbol}
13130dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        and $CompleteSignature{2}{$PSymbol}{"MnglName"})
13131dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
13132dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative{$Symbol} = $PSymbol;
13133dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative_B{$PSymbol} = $Symbol;
13134dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if(not defined $CompleteSignature{1}{$PSymbol}
13135dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
13136dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $SourceReplacement{$Symbol} = $PSymbol;
13137dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
13138dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        }
13139dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
13140dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $PSymbol = $Symbol;
13141dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
131421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
131431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
131441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
131451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "";
131461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
131471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
131480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getSymKind($$)
131490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
131500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
131510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"})
131520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
131530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Global_Data";
131540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
131550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($CompleteSignature{$LibVersion}{$Symbol}{"Class"})
131560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
131570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Method";
131580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
131590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Function";
131600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
131610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
131628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub mergeSymbols($)
13163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
131641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
13165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SubProblems = ();
13166f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
131671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    mergeBases($Level);
131681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
13169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AddedOverloads = ();
131701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
13171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check all added exported symbols
131721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}) {
13173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
131750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{1}{$Symbol}
131760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Header"})
131770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check added symbol
131780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
131791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13180850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 2, "Affected", $Level)) {
131811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
131821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
131831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
131851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedOverloads{get_symbol_prefix($Symbol, 2)}{get_symbol_suffix($Symbol, 1)} = $Symbol;
13186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
131871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{2}{$Symbol}{"Override"})
131881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1318962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{2}{$Symbol}{"Class"};
1319062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{2}{$Cid}{"Name"};
131910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $CompleteSignature{1}{$OverriddenMethod} and $CompleteSignature{1}{$OverriddenMethod}{"Virt"}
13192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $CompleteSignature{1}{$OverriddenMethod}{"Private"})
131930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
131940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{1}{$AffectedClass_Name})
131950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in previous version
131960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($TName_Tid{1}{$AffectedClass_Name}, 1))
131970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
131980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$OverriddenMethod}{"Overridden_Virtual_Method"}{$tr_name{$Symbol}}}=(
131990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($Symbol, 2),
132010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($OverriddenMethod, 2),
1320274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($Symbol, 2));
132030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
132081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
132091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check all removed exported symbols
132101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
13211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{2}{$Symbol}
132140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$Symbol}{"Header"})
132150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check removed symbol
132160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
132171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
132191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip private methods
132201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13222850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
132231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
132261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{1}{$Symbol}{"Override"})
132271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1322862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
1322962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{1}{$Cid}{"Name"};
13230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$OverriddenMethod}
132310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$OverriddenMethod}{"Virt"})
132320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{2}{$AffectedClass_Name})
132340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in newer version
132350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($CompleteSignature{1}{$Symbol}{"Class"}, 1))
132360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Overridden_Virtual_Method_B"}{$tr_name{$OverriddenMethod}}}=(
132380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($OverriddenMethod, 1),
132400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($Symbol, 1),
1324174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($OverriddenMethod, 1));
132420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
132476fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        and $OStarget eq "windows")
13248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register the reason of symbol name change
1324962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $NewSym = $mangled_name{2}{$tr_name{$Symbol}})
13250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1325162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($AddedInt{$Level}{$NewSym})
13252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1325362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Static"} ne $CompleteSignature{2}{$NewSym}{"Static"})
13254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1325562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Static"})
132561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
132571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Static"}{$tr_name{$Symbol}}}=(
132581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1326062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
132621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
132631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13264fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Static"}{$tr_name{$Symbol}}}=(
132651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1326762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1327062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Virt"} ne $CompleteSignature{2}{$NewSym}{"Virt"})
13271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1327262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Virt"})
132731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
132741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Virtual"}{$tr_name{$Symbol}}}=(
132751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1327762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
132791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
132801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Virtual"}{$tr_name{$Symbol}}}=(
132821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
132831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1328462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1328762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId1 = $CompleteSignature{1}{$Symbol}{"Return"};
1328862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId2 = $CompleteSignature{2}{$NewSym}{"Return"};
1328962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName1 = $TypeInfo{1}{$RTId1}{"Name"};
1329062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName2 = $TypeInfo{2}{$RTId2}{"Name"};
1329162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($RTName1 ne $RTName2)
13292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Symbol_Changed_Return";
132941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"Data"}) {
13295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Global_Data_Symbol_Changed_Type";
13296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
132971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{$tr_name{$Symbol}}}=(
132981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1329962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Old_Type"=>$RTName1,
1330062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Type"=>$RTName2,
133011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1330262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
133091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Prefix = get_symbol_prefix($Symbol, 1);
13310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my @Overloads = sort keys(%{$AddedOverloads{$Prefix}})
133111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $AddedOverloads{$Prefix}{get_symbol_suffix($Symbol, 1)})
13312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # changed signature: params, "const"-qualifier
1331362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NewSym = $AddedOverloads{$Prefix}{$Overloads[0]};
133141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($CompleteSignature{1}{$Symbol}{"Constructor"})
133151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13316f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(C[1-2][EI])/)
13317989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $CtorType = $1;
13319f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(C[1-2][EI])/$CtorType/g;
13320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
133221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                elsif($CompleteSignature{1}{$Symbol}{"Destructor"})
133231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13324f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(D[0-2][EI])/)
13325989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $DtorType = $1;
13327f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(D[0-2][EI])/$DtorType/g;
13328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13330dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $NS1 = $CompleteSignature{1}{$Symbol}{"NameSpace"};
1333162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NS2 = $CompleteSignature{2}{$NewSym}{"NameSpace"};
13332dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if((not $NS1 and not $NS2) or ($NS1 and $NS2 and $NS1 eq $NS2))
13333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # from the same class and namespace
133341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Const"}
1333562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Const"})
13336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "const" to non-"const"
13337fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Const"}{$tr_name{$Symbol}}}=(
1333862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Type_Name"=>$TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"},
133391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1334062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1334262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Const"}
1334562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Const"})
13346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"const" to "const"
133470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Const"}{$tr_name{$Symbol}}}=(
133481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1334962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1335162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Volatile"}
1335462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Volatile"})
13355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "volatile" to non-"volatile"
13356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13357fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Volatile"}{$tr_name{$Symbol}}}=(
133581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1335962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1336162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
133631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Volatile"}
1336462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Volatile"})
13365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"volatile" to "volatile"
133660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Volatile"}{$tr_name{$Symbol}}}=(
133671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1336862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1337062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1337262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(get_symbol_suffix($Symbol, 0) ne get_symbol_suffix($NewSym, 0))
13373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # params list
133741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Symbol_Changed_Parameters"}{$tr_name{$Symbol}}}=(
133751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1337662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
133771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1337862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
133841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
133851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # checking symbols
13386f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $CurrentSymbol = $Symbol;
13387f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
133881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
133891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
133901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
133911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
133921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
133931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
133941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary
133951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $SV)
133961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # symbol without version
133971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $VSym = $SymVer{1}{$Symbol})
133981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # the symbol is linked with versioned symbol
133991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{2}{$VSym}{"MnglName"})
134001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # show report for symbol@ver only
134011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
134031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not link_symbol($VSym, 2, "-Deps"))
134041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed version: sym@v1 to sym@v2
134051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                      # do NOT show report for symbol
134061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
13408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PSymbol = $Symbol;
134121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source"
134131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and my $S = $SourceReplacement{$Symbol})
134141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # take a source-compatible replacement function
134151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $PSymbol = $S;
134161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
13418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # private symbols
13419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
134221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not defined $CompleteSignature{2}{$PSymbol})
134231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no info
134241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
134251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"MnglName"}
134271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"MnglName"})
134281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no mangled name
13429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
134321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"Header"})
13433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # without a header
13434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"PureVirt"}
134389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"PureVirt"})
134399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became pure
134409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
134439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"PureVirt"})
134449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became non-pure
134459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level))
134499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
134509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($PSymbol, 2, "Affected + InlineVirt", $Level))
134539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
134549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
134559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
134569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1345762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.13") and checkDump(2, "2.13"))
134580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
134590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"}
134600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Data"})
134610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
134620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value1 = $CompleteSignature{1}{$Symbol}{"Value"};
134630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value2 = $CompleteSignature{2}{$PSymbol}{"Value"};
134640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $Value1)
134650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
134660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value1 = showVal($Value1, $CompleteSignature{1}{$Symbol}{"Return"}, 1);
134670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $Value2)
134680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
134690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        $Value2 = showVal($Value2, $CompleteSignature{2}{$PSymbol}{"Return"}, 2);
134700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($Value1 ne $Value2)
134710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
134720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Global_Data_Value_Changed"}{""}}=(
134730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Old_Value"=>$Value1,
134740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "New_Value"=>$Value2,
134750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Target"=>get_Signature($Symbol, 1)  );
134760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
134770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
134780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
134790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
134800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
13481850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
134820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Private"})
134830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
134840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Private"}{""}}=(
134850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
134860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
134870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(not $CompleteSignature{1}{$Symbol}{"Protected"}
134880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"Protected"})
134890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
134900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Protected"}{""}}=(
134910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
134920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
134930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($CompleteSignature{1}{$Symbol}{"Protected"}
134940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"Protected"})
134950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
134960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Public"}{""}}=(
134970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
134980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
134990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking virtual table
135011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        mergeVirtualTables($Symbol, $Level);
135021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
13503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($COMPILE_ERRORS)
13504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # if some errors occurred at the compiling stage
13505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # then some false positives can be skipped here
135061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Data"} and $CompleteSignature{2}{$PSymbol}{"Data"}
1350762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $GlobalDataObject{2}{$Symbol})
13508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # missed information about parameters in newer version
13509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1351162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"} and not $GlobalDataObject{1}{$Symbol}
135121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Data"})
135139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # missed information about parameters in older version
13514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
13518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking attributes
135191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Static"}
135209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
135221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Static"}{""}}=(
135231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif(not $CompleteSignature{2}{$PSymbol}{"Static"}
135279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
13529fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Static"}{""}}=(
135301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($CompleteSignature{1}{$Symbol}{"Virt"} and $CompleteSignature{2}{$PSymbol}{"Virt"})
135341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or ($CompleteSignature{1}{$Symbol}{"PureVirt"} and $CompleteSignature{2}{$PSymbol}{"PureVirt"}))
13535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative position of virtual and pure virtual methods
135361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
13537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13538dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Symbol}{"RelPos"} and defined $CompleteSignature{2}{$PSymbol}{"RelPos"}
13539dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"RelPos"}!=$CompleteSignature{2}{$PSymbol}{"RelPos"})
13540dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # top-level virtual methods only
135411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Class_Id = $CompleteSignature{1}{$Symbol}{"Class"};
1354262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Class_Name = $TypeInfo{1}{$Class_Id}{"Name"};
13543dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{1}{$Class_Name} and defined $VirtualTable{2}{$Class_Name}
13544dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    and $VirtualTable{1}{$Class_Name}{$Symbol}!=$VirtualTable{2}{$Class_Name}{$Symbol})
135451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # check the absolute position of virtual method (including added and removed methods)
1354662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %Class_Type = get_Type($Class_Id, 1);
135471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Virtual_Method_Position";
135481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
135491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Pure_Virtual_Method_Position";
135501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
135511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isUsedClass($Class_Id, 1, $Level))
13552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
135531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            my @Affected = ($Symbol, keys(%{$OverriddenMethods{1}{$Symbol}}));
135549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            foreach my $ASymbol (@Affected)
135551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            {
135569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
135579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                    next;
135589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                }
135599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$MnglName}}}=(
135601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Type_Name"=>$Class_Type{"Name"},
135611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Old_Value"=>$CompleteSignature{1}{$Symbol}{"RelPos"},
135621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Value"=>$CompleteSignature{2}{$PSymbol}{"RelPos"},
1356374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                                    "Target"=>get_Signature($Symbol, 1));
135641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
135651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $VTableChanged_M{$Class_Type{"Name"}} = 1;
13566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
135721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{2}{$PSymbol}{"PureVirt"})
13573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT check type changes in pure virtuals
13574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13576ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
135771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/
135781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})==keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C/C++: changes in parameters
135801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking parameters
13582ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 1);
13583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
13586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C: added/removed parameters
135871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking added parameters
13589dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
1359062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType2_Name = $TypeInfo{2}{$PType2_Id}{"Name"};
1359162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType2_Name eq "...");
1359262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1359362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName_Old = (defined $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos})?$CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"}:"";
13594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_Prev = "-1";
1359562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added unnamed parameter ( pN )
1359762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 1);
1359862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 2);
13599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions1==-1 or $#Positions2>$#Positions1) {
13600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_Prev = "lost";
13601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
1360462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ParamPos_Prev = find_ParamPair_Pos_byName($PName, $Symbol, 1);
13605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_Prev eq "lost")
13607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
136081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Added_Parameter";
1361162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Added_Unnamed_Parameter";
13613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
136140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1361562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Target"=>$PName,
13616f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1361762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType2_Name,
136181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
13621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13622f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType2_Id, $TypeInfo{2});
1362362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
13624f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{1});
1362562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType2_Name eq $TypeInfo{1}{$PairType_Id}{"Name"})
1362662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_Old, $Symbol, 2) eq "lost")
13627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
1362862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName_Old!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
136300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
1363162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Target"=>$PName_Old,
13632f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1363362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType2_Name,
1363462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Old_Value"=>$PName_Old,
1363562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "New_Value"=>$PName,
136361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Added_Middle_Parameter";
1364262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Added_Middle_Unnamed_Parameter";
13644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
136450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1364662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Target"=>$PName,
13647f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1364862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType2_Name,
136491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
136541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # check relevant parameters
13656dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
136571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $ParamName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # FIXME: find relevant parameter by name
136591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})
13660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13661dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
136621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ParamName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1366362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TypeInfo{1}{$PType1_Id}{"Name"} eq $TypeInfo{2}{$PType2_Id}{"Name"}
1366462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    or ($ParamName1!~/\Ap\d+\Z/i and $ParamName1 eq $ParamName2)) {
13665ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 0);
13666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
136691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking removed parameters
13671dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
1367262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType1_Name = $TypeInfo{1}{$PType1_Id}{"Name"};
1367362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType1_Name eq "...");
13674ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13675ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName_New = (defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})?$CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"}:"";
13676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_New = "-1";
13677ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed unnamed parameter ( pN )
1367962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 1);
1368062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 2);
13681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions2==-1 or $#Positions2<$#Positions1) {
13682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_New = "lost";
13683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13686ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    $ParamPos_New = find_ParamPair_Pos_byName($PName, $Symbol, 2);
13687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_New eq "lost")
13689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
136901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}})-1)
13691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Removed_Parameter";
13693ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Removed_Unnamed_Parameter";
13695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
136960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13697ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            "Target"=>$PName,
13698f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1369962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType1_Name,
137001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
137021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($ParamPos<keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13704f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType1_Id, $TypeInfo{1});
1370562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
13706f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{2});
1370762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType1_Name eq $TypeInfo{2}{$PairType_Id}{"Name"})
13708ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_New, $Symbol, 1) eq "lost")
13709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13710ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName_New!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
137120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
13713ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Target"=>$PName,
13714f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1371562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType1_Name,
13716ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Old_Value"=>$PName,
13717ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "New_Value"=>$PName_New,
137181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Removed_Middle_Parameter";
13724ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Removed_Middle_Unnamed_Parameter";
13726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
137270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13728ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                "Target"=>$PName,
13729f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1373062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType1_Name,
137311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking return type
137381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType1_Id = $CompleteSignature{1}{$Symbol}{"Return"};
137391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType2_Id = $CompleteSignature{2}{$PSymbol}{"Return"};
13740f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %RC_SubProblems = detectTypeChange($ReturnType1_Id, $ReturnType2_Id, "Return", $Level);
13741fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13742f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubProblemType (keys(%RC_SubProblems))
13743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13744f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $New_Value = $RC_SubProblems{$SubProblemType}{"New_Value"};
13745f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Old_Value = $RC_SubProblems{$SubProblemType}{"Old_Value"};
13746fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %ProblemTypes = ();
13747f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13748fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13750fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type_And_Size") {
13751fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_And_Size"} = 1;
13752fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13753fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_Format") {
13754fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_Format"} = 1;
13755fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
13757fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type"} = 1;
13758fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13760fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13761fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13762fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13763fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13765fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RR = removedQual($Old_Value, $New_Value, "const"))
13766fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # const to non-const
13767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RR==2) {
13768fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Removed_Const"} = 1;
13769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Non_Const"} = 1;
13772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    elsif(my $RA = addedQual($Old_Value, $New_Value, "const"))
13776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # non-const to const
13777fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Added_Const"} = 1;
13779fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13780fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13781fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Const"} = 1;
13782fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13783fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13787fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else
13788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13792fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13794fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(checkDump(1, "2.6") and checkDump(2, "2.6"))
13795fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13796fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(addedQual($Old_Value, $New_Value, "volatile"))
13797fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13798fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Value_Became_Volatile"} = 1;
13799fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Level ne "Source"
13800fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13801fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                $ProblemTypes{"Return_Type"} = 1;
13802fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13803fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13804fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13805fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RA = addedQual($Old_Value, $New_Value, "const"))
138069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
13807fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Added_Const"} = 1;
13809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13811fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Const"} = 1;
13812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Level ne "Source"
13814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13815fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type"} = 1;
13816fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13820f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Level eq "Binary"
13821f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and not $CompleteSignature{1}{$Symbol}{"Data"})
13822f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
13823f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my ($Arch1, $Arch2) = (getArch(1), getArch(2));
13824f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Arch1 eq "unknown" or $Arch2 eq "unknown")
13825f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                { # if one of the architectures is unknown
13826f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    # then set other arhitecture to unknown too
13827f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    ($Arch1, $Arch2) = ("unknown", "unknown");
13828f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13829f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my (%Conv1, %Conv2) = ();
13830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UseConv_Real{1}{"R"} and $UseConv_Real{2}{"R"})
13831f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13832f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Real($CompleteSignature{1}{$Symbol});
13833f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Real($CompleteSignature{2}{$PSymbol});
13834f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13835f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                else
13836f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13837f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Model($CompleteSignature{1}{$Symbol}, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
13838f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Model($CompleteSignature{2}{$PSymbol}, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
13839f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13840f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13841f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($SubProblemType eq "Return_Type_Became_Void")
13842f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13843f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13844f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13845f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack") {
13846fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Stack_Layout"} = 1;
13847f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13848f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv1{"Hidden"}) {
13849fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Register"} = 1;
13850f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13851f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13852f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13853f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_From_Void")
13854f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13855f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13856f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13857f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv2{"Method"} eq "stack") {
13858fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Stack_Layout"} = 1;
13859f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13860f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv2{"Hidden"}) {
13861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Register"} = 1;
13862f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13863f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13864f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13865f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type"
13866f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13867f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13868f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13869f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Method"} ne $Conv2{"Method"})
13870f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13871f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack")
13872f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        { # returns in a register instead of a hidden first parameter
13873fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Stack_To_Register"} = 1;
13874f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13875f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        else {
13876fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Register_To_Stack"} = 1;
13877f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13878f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13879f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    else
13880f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13881f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "reg")
13882f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
13883f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            if($Conv1{"Registers"} ne $Conv2{"Registers"})
13884f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            {
13885f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if($Conv1{"Hidden"}) {
13886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Was_Hidden_Parameter"} = 1;
13887f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13888f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                elsif($Conv2{"Hidden"}) {
13889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Became_Hidden_Parameter"} = 1;
13890f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13891f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                else {
13892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register"} = 1;
13893f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13894f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            }
13895f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13896f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13897f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13898f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
13899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not keys(%ProblemTypes))
13901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # default
13902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $ProblemTypes{$SubProblemType} = 1;
13903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $ProblemType (keys(%ProblemTypes))
13906fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # additional
13907f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $CompatProblems{$Level}{$Symbol}{$ProblemType}{"retval"} = $RC_SubProblems{$SubProblemType};
139089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
13909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ReturnType1_Id and $ReturnType2_Id)
13911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @RecurTypes = ();
13913f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Sub_SubProblems = mergeTypes($ReturnType1_Id, $ReturnType2_Id, $Level);
13914f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13915f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $AddProblems = {};
13916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13919fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Binary")
13920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
13921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(get_PLevel($ReturnType1_Id, 1)==0)
13922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
1392333ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        if(defined $Sub_SubProblems->{"DataType_Size"})
13924fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        { # add "Global_Data_Size" problem
13925d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1392633ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            foreach my $Loc (keys(%{$Sub_SubProblems->{"DataType_Size"}}))
1392733ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            {
1392833ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                if(index($Loc,"->")==-1)
13929d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                {
13930d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    if($Loc eq $Sub_SubProblems->{"DataType_Size"}{$Loc}{"Type_Name"})
13931d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    {
13932d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        $AddProblems->{"Global_Data_Size"}{$Loc} = $Sub_SubProblems->{"DataType_Size"}{$Loc}; # add a new problem
13933d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        last;
13934d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    }
1393533ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                }
13936fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13937fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13938fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13939f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if(not defined $AddProblems->{"Global_Data_Size"})
13940fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(defined $GlobalDataObject{1}{$Symbol}
13942fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        and defined $GlobalDataObject{2}{$Symbol})
13943fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13944fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Size = $GlobalDataObject{1}{$Symbol};
13945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Size = $GlobalDataObject{2}{$Symbol};
13946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Old_Size!=$New_Size)
13947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            {
13948f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $AddProblems->{"Global_Data_Size"}{"retval"} = {
13949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "Old_Size"=>$Old_Size*$BYTE_SIZE,
13950f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "New_Size"=>$New_Size*$BYTE_SIZE };
13951fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13952fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13953fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13955fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13956f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13957f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$AddProblems}))
13958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13959f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$AddProblems->{$SubProblemType}}))
13960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1396133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1396233ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1396333ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1396433ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13965f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $AddProblems->{$SubProblemType}{$SubLocation};
13966f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
13967f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
13968f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13969f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13970f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
13971f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
13972f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                {
1397333ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1397433ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1397533ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1397633ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13977f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
13978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking object type
1398362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId1 = $CompleteSignature{1}{$Symbol}{"Class"};
1398462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId2 = $CompleteSignature{2}{$PSymbol}{"Class"};
1398562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ObjTId1 and $ObjTId2
139861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"})
13987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1398862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr1_Id = getTypeIdByName($TypeInfo{1}{$ObjTId1}{"Name"}."*const", 1);
1398962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr2_Id = getTypeIdByName($TypeInfo{2}{$ObjTId2}{"Name"}."*const", 2);
13990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ThisPtr1_Id and $ThisPtr2_Id)
13991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @RecurTypes = ();
13993f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Sub_SubProblems = mergeTypes($ThisPtr1_Id, $ThisPtr2_Id, $Level);
13994f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13996f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
13997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NewLocation = ($SubLocation)?"this->".$SubLocation:"this";
13999f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
140051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
140061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeVTables($Level);
140071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
14008850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompatProblems{$Level}})) {
14009850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
14010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
14011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub rmQuals($$)
140140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
140160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
140170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
140180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Qual eq "all")
140200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # all quals
140210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Qual = "const|volatile|restrict";
140220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1402362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~s/\b$Qual\b//) {
140249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Value = formatName($Value, "T");
140250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
140270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub cmpBTypes($$$$)
140300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($T1, $T2, $V1, $V2) = @_;
140320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T1 = uncover_typedefs($T1, $V1);
140330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T2 = uncover_typedefs($T2, $V2);
140340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return (rmQuals($T1, "all") eq rmQuals($T2, "all"));
140350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub addedQual($$$)
140380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($New_Value, $Old_Value, 2, 1, $Qual);
140410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub removedQual($$$)
14044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
140451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($Old_Value, $New_Value, 1, 2, $Qual);
140470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removedQual_I($$$$$)
140500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $V1, $V2, $Qual) = @_;
140520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Old_Value = uncover_typedefs($Old_Value, $V1);
140530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $New_Value = uncover_typedefs($New_Value, $V2);
140549e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
140550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Old_Value eq $New_Value)
140560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # equal types
14057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1405962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Old_Value!~/\b$Qual\b/)
140600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # without a qual
140610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 0;
140620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1406362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($New_Value!~/\b$Qual\b/)
140640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # became non-qual
140650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
140660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    else
140680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
140690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ1 = getQualModel($Old_Value, $Qual);
140700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ2 = getQualModel($New_Value, $Qual);
140710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        foreach (0 .. $#BQ1)
140720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # removed qual
140730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BQ1[$_]==1
140740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BQ2[$_]!=1)
140750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
140760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 2;
140770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
14078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualModel($$)
140840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
140860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
140870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
140880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # cleaning
140919e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    while($Value=~/(\w+)/)
140929e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    {
140939e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        my $W = $1;
140949e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
140959e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        if($W eq $Qual) {
140969e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            $Value=~s/\b$W\b/\@/g;
140979e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        }
140989e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        else {
140999e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            $Value=~s/\b$W\b//g;
141009e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        }
141010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141029e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
141039e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    $Value=~s/\@/$Qual/g;
141040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Value=~s/[^\*\&\w]+//g;
141050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # modeling
141070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int*const*const == 011
141080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int**const == 001
141090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Model = ();
141100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Elems = split(/[\*\&]/, $Value);
141110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not @Elems) {
141120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return (0);
141130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach (@Elems)
141150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
141160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($_ eq $Qual) {
141170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 1);
141180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
141200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 0);
141210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return @Model;
141250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141274b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %StringTypes = map {$_=>1} (
141284b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char*",
141294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const*"
141304b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %CharTypes = map {$_=>1} (
141334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char",
141344b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const"
141354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showVal($$$)
141380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $TypeId, $LibVersion) = @_;
14140f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
14141a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $TName = uncover_typedefs($PureType{"Name"}, $LibVersion);
1414201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(substr($Value, 0, 2) eq "_Z")
1414301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
1414401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Unmangled = $tr_name{$Value}) {
1414501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Unmangled;
1414601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1414701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
141484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $StringTypes{$TName} or $TName=~/string/i)
141490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # strings
141500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\"$Value\"";
141510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $CharTypes{$TName})
141530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # characters
141540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\'$Value\'";
141550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($Value eq "")
141574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    { # other
141584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return "\'\'";
141594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
141600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
141610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14163fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub getRegs($$$)
14164fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
14165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Symbol, $Pos) = @_;
14166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}{"Reg"})
14168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14169fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %Regs = ();
14170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Elem (sort keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}}))
14171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14172ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if($Elem=~/\A$Pos([\.\+]|\Z)/) {
14173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Regs{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}{$Elem}} = 1;
14174fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14175fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14176fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14177fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return join(", ", sort keys(%Regs));
14178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
141791fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    elsif(defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}
141801fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{0}
141811fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    and not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{0}{"offset"})
141821fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    {
141831fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        return "unknown";
141841fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
14185fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14186fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return undef;
14187fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
14188fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14189ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenkosub mergeParameters($$$$$$)
14190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14191ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    my ($Symbol, $PSymbol, $ParamPos1, $ParamPos2, $Level, $ChkRnmd) = @_;
141920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Symbol) {
141930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
141940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14195dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"type"};
14196dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"name"};
14197dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"type"};
14198dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"name"};
141990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $PType1_Id
142000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    or not $PType2_Id) {
142010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
142020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14203ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14204f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
14205177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # do not merge "this"
14206177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($PName1 eq "this" or $PName2 eq "this") {
14207177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return;
14208177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
14209ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    }
14210ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
1421162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($PType1_Id, 1);
1421262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($PType2_Id, 2);
1421352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1421452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %PureType1 = get_PureType($PType1_Id, $TypeInfo{1});
1421552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1421662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType1 = get_BaseType($PType1_Id, 1);
1421762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType2 = get_BaseType($PType2_Id, 2);
1421852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
142190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Parameter_Location = ($PName1)?$PName1:showPos($ParamPos1)." Parameter";
14220ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
142211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
142221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
1422362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.6.1") and checkDump(2, "2.6.1"))
142241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # "reg" attribute added in ACC 1.95.1 (dump 2.6.1 format)
142251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Non_Register"}{$Parameter_Location}}=(
14229dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14230f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
142311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
142321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif(not $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Register"}{$Parameter_Location}}=(
14236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14237f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
142381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
14239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14240fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14241fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $UsedDump{1}{"DWARF"}
14242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and defined $UsedDump{2}{"DWARF"})
14243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "3.0") and checkDump(2, "3.0"))
14245fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14246fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Old_Regs = getRegs(1, $Symbol, $ParamPos1);
14247fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $New_Regs = getRegs(2, $PSymbol, $ParamPos2);
142481fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
142491fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                if($Old_Regs ne "unknown"
142501fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                and $New_Regs ne "unknown")
14251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
142521fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    if($Old_Regs and $New_Regs)
142531fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    {
142541fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        if($Old_Regs ne $New_Regs)
142551fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        {
142561fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Register"}{$Parameter_Location}}=(
142571fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Target"=>$PName1,
142581fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
142591fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "Old_Value"=>$Old_Regs,
142601fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                                "New_Value"=>$New_Regs  );
142611fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        }
142621fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    }
142631fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    elsif($Old_Regs and not $New_Regs)
14264fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
142651fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_From_Register"}{$Parameter_Location}}=(
142661fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Target"=>$PName1,
142671fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
142681fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                            "Old_Value"=>$Old_Regs  );
142691fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    }
142701fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    elsif(not $Old_Regs and $New_Regs)
142711fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                    {
142721fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_To_Register"}{$Parameter_Location}}=(
14273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14274f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Regs  );
14276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14277fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
142781fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
14279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if((my $Old_Offset = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"offset"}) ne ""
14280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and (my $New_Offset = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"offset"}) ne "")
14281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Offset ne $New_Offset)
14283fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14284f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start1 = $CompleteSignature{1}{$Symbol}{"Param"}{0}{"offset"};
14285f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start2 = $CompleteSignature{2}{$Symbol}{"Param"}{0}{"offset"};
14286f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14287f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $Old_Offset = $Old_Offset - $Start1;
14288f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $New_Offset = $New_Offset - $Start2;
14289f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14290f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if($Old_Offset ne $New_Offset)
14291f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
14292f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Offset"}{$Parameter_Location}}=(
14293f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Target"=>$PName1,
14294f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14295f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Old_Value"=>$Old_Offset,
14296f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "New_Value"=>$New_Offset  );
14297f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
14298fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14303177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(checkDump(1, "2.0") and checkDump(2, "2.0")
14304177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $UsedDump{1}{"V"} ne "3.1" and $UsedDump{2}{"V"} ne "3.1")
14305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # "default" attribute added in ACC 1.22 (dump 2.0 format)
14306177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      # broken in 3.1, fixed in 3.2
143070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_Old = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"default"};
143080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_New = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"default"};
1430962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1431062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and checkDump(2, "2.13"))
143110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
143120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_Old and defined $Value_New)
143130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
1431452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Name"} eq "bool"
143150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $Value_Old eq "false" and $Value_New eq "0")
143160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # int class::method ( bool p = 0 );
143170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # old ABI dumps: "false"
143180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # new ABI dumps: "0"
143190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value_Old = "0";
143200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
14321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1432301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not checkDump(1, "2.18")
1432401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and checkDump(2, "2.18"))
1432501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # support for old ABI dumps
1432601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not defined $Value_Old
1432701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and substr($Value_New, 0, 2) eq "_Z") {
1432801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Value_Old = $Value_New;
1432901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
1433001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
143310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Value_Old)
14332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
143330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_Old = showVal($Value_Old, $PType1_Id, 1);
143340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_New)
14335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Value_New = showVal($Value_New, $PType2_Id, 2);
143370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Value_Old ne $Value_New)
143380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # FIXME: how to distinguish "0" and 0 (NULL)
143391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Changed"}{$Parameter_Location}}=(
14340dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Target"=>$PName1,
14341f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "Old_Value"=>$Value_Old,
143430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "New_Value"=>$Value_New  );
14344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Removed"}{$Parameter_Location}}=(
143490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>$PName1,
14350f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Old_Value"=>$Value_Old  );
14352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(defined $Value_New)
143550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
143560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_New = showVal($Value_New, $PType2_Id, 2);
143570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Added"}{$Parameter_Location}}=(
143580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>$PName1,
14359f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "New_Value"=>$Value_New  );
143610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
14362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14363ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14364ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    if($ChkRnmd)
14365ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    {
14366ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($PName1 and $PName2 and $PName1 ne $PName2
14367ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PType1_Id!=-1 and $PType2_Id!=-1
14368ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PName1!~/\Ap\d+\Z/ and $PName2!~/\Ap\d+\Z/)
14369ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # except unnamed "..." value list (Id=-1)
14370ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos1)." Parameter"}}=(
14371ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Target"=>$PName1,
14372f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14373ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14374ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Old_Value"=>$PName1,
14375ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Value"=>$PName2,
14376ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Signature"=>get_Signature($Symbol, 2)  );
14377ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
14378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14379ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type change (replace)
14381dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my %SubProblems = detectTypeChange($PType1_Id, $PType2_Id, "Parameter", $Level);
14382f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add new problems, remove false alarms
14385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14387fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # quals
14389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SubProblemType eq "Parameter_Type"
14390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_And_Size"
14391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_Format")
14392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1439362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(addedQual($Old_Value, $New_Value, "restrict")) {
143960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Restrict"}} = %{$SubProblems{$SubProblemType}};
143971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(removedQual($Old_Value, $New_Value, "restrict")) {
14399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Restrict"}} = %{$SubProblems{$SubProblemType}};
14400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(removedQual($Old_Value, $New_Value, "volatile")) {
14405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Volatile"}} = %{$SubProblems{$SubProblemType}};
14406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2{"Type"} eq "Const" and $BaseType2{"Name"} eq $Type1{"Name"}
14409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # int to "int const"
14411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14413fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif($Type1{"Type"} eq "Const" and $BaseType1{"Name"} eq $Type2{"Name"}
14414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "int const" to int
14416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14418fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
14419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # "const" to non-"const"
14420fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($RR==2) {
14421fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Removed_Const"}} = %{$SubProblems{$SubProblemType}};
14422fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
14424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Const"}} = %{$SubProblems{$SubProblemType}};
14425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Level eq "Source")
14431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14437fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SubProblemType eq "Parameter_Type")
14438fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14439fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
14440fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($SubProblems{$SubProblemType});
14441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14444fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify/register problems
14448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14450f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $New_Size = $SubProblems{$SubProblemType}{"New_Size"};
14451f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $Old_Size = $SubProblems{$SubProblemType}{"Old_Size"};
14452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NewProblemType = $SubProblemType;
14454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Old_Value eq "..." and $New_Value ne "...")
14455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "..." to "int"
14456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos1==0)
14457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $NewProblemType = "Parameter_Became_Non_VaList";
14461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($New_Value eq "..." and $Old_Value ne "...")
14463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "int" to "..."
14464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos2==0)
14465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $NewProblemType = "Parameter_Became_VaList";
14469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
144701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($Level eq "Binary" and ($SubProblemType eq "Parameter_Type_And_Size"
14471f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type" or $SubProblemType eq "Parameter_Type_Format"))
14472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Arch1, $Arch2) = (getArch(1), getArch(2));
14474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Arch1 eq "unknown"
14475f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            or $Arch2 eq "unknown")
14476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if one of the architectures is unknown
14477f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko              # then set other arhitecture to unknown too
14478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($Arch1, $Arch2) = ("unknown", "unknown");
14479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14480f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my (%Conv1, %Conv2) = ();
14481fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UseConv_Real{1}{"P"} and $UseConv_Real{2}{"P"})
14482f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # real
14483f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Real($CompleteSignature{1}{$Symbol}, $ParamPos1);
14484f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Real($CompleteSignature{2}{$Symbol}, $ParamPos2);
14485f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14486f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            else
14487f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # model
14488f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Model($CompleteSignature{1}{$Symbol}, $ParamPos1, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
14489f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Model($CompleteSignature{2}{$Symbol}, $ParamPos2, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
14490f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14491f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Conv1{"Method"} eq $Conv2{"Method"})
14492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14493f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack")
14494f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14495f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Old_Size ne $New_Size) { # FIXME: isMemPadded, getOffset
14496f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Stack";
14497f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14499f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "reg")
14500f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14501f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Registers"} ne $Conv2{"Registers"}) {
14502f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Register";
14503f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
145061fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            elsif($Conv1{"Method"} ne "unknown"
145071fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            and $Conv2{"Method"} ne "unknown")
14508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14509f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack") {
14510f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Stack_To_Register";
14511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14512f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "register") {
14513f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Register_To_Stack";
14514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14516f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"Old_Reg"} = $Conv1{"Registers"};
14517f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"New_Reg"} = $Conv2{"Registers"};
14518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
145191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}=(
14520dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            "Target"=>$PName1,
14521f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
145221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            "New_Signature"=>get_Signature($Symbol, 2) );
145231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
14524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14525f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @RecurTypes = ();
14527f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type definition changes
14529f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Sub_SubProblems = mergeTypes($PType1_Id, $PType2_Id, $Level);
14530f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14532f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewProblemType = $SubProblemType;
14535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubProblemType eq "DataType_Size")
14536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1453752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Type"}!~/\A(Pointer|Ref)\Z/ and $SubLocation!~/\-\>/)
14538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # stack has been affected
14539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $NewProblemType = "DataType_Size_And_Stack";
14540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewLocation = ($SubLocation)?$Parameter_Location."->".$SubLocation:$Parameter_Location;
14543f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byName($$$)
14549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
145511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
145531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"name"} eq $Name)
14555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $ParamPos;
14557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
14560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byTypeAndPos($$$$$)
14563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TypeName, $MediumPos, $Order, $Symbol, $LibVersion) = @_;
14565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Positions = ();
145661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "backward" and $ParamPos>$MediumPos);
14569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "forward" and $ParamPos<$MediumPos);
145701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"type"};
1457262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$PTypeId}{"Name"} eq $TypeName) {
14573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Positions, $ParamPos);
14574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Positions;
14577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeIdByName($$)
14580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14581e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
14582e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    return $TName_Tid{$LibVersion}{formatName($TypeName, "T")};
14583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
145858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes($$$)
145868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
145878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]}) {
145888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]};
145898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
145908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($_[0], $_[1], \@RecurTypes_Diff))
145918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip recursive declarations
145928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
145938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
145948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($_[0], $_[1], \@RecurTypes_Diff);
145968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Diff = diffTypes_I(@_);
145978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pop(@RecurTypes_Diff);
145988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]} = $Diff);
146008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
146018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes_I($$$)
14603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
146041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
146058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14606f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14607f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
146088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
14610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # equal types
14611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
146139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Type1_Pure{"Name"} eq "void")
146149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # from void* to something
146159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return 0;
146169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
14617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"}=~/\*/
14618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type2_Pure{"Name"}=~/\*/)
14619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compared in detectTypeChange()
14620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
146228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %FloatType = map {$_=>1} (
14624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "float",
14625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "double",
14626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "long double"
14627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
14628fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14629fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T1 = $Type1_Pure{"Type"};
14630fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T2 = $Type2_Pure{"Type"};
14631fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14632fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Struct"
14633fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Class")
14634fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14635fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T2 = "Struct";
14636fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14637fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14638fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Class"
14639fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Struct")
14640fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14641fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T1 = "Struct";
14642fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14643fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14644fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 ne $T2)
14645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
14646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic"
14647fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T2 eq "Enum")
14648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "int" to "enum"
14649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T2 eq "Intrinsic"
14652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T1 eq "Enum")
14653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "enum" to "int"
14654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
14657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # union to struct
14658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
14659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
14660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
14663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic")
14665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($FloatType{$Type1_Pure{"Name"}}
14667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $FloatType{$Type2_Pure{"Name"}})
14668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "float" to "double"
14669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # "float" to "int"
146701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source")
146711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Safe
146721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 0;
146731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
146741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
146751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 1;
146761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T1=~/Class|Struct|Union|Enum/)
14680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs1 = keys(%{$Type1_Pure{"Memb"}});
14682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs2 = keys(%{$Type2_Pure{"Memb"}});
14683fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not @Membs1
14684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            or not @Membs2)
14685570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # private
14686570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return 0;
14687570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
14688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($#Membs1!=$#Membs2)
14689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different number of elements
14690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
14691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14692fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($T1 eq "Enum")
14693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
14695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # compare elements by name and value
14696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"}
14697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or $Type1_Pure{"Memb"}{$Pos}{"value"} ne $Type2_Pure{"Memb"}{$Pos}{"value"})
14698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # different names
14699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return 1;
14700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
147068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
147071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source")
147081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
147091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"})
147101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # different names
147111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            return 1;
147121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
147131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
147148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT1 = %{$TypeInfo{1}{$Type1_Pure{"Memb"}{$Pos}{"type"}}};
147168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT2 = %{$TypeInfo{2}{$Type2_Pure{"Memb"}{$Pos}{"type"}}};
147178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($MT1{"Name"} ne $MT2{"Name"}
147198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    or isAnon($MT1{"Name"}) or isAnon($MT2{"Name"}))
147208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
147218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL1 = get_PLevel($MT1{"Tid"}, 1);
147228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL2 = get_PLevel($MT2{"Tid"}, 2);
147238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($PL1 ne $PL2)
147258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different pointer level
147268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        # compare base types
147308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT1 = get_BaseType($MT1{"Tid"}, 1);
147318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT2 = get_BaseType($MT2{"Tid"}, 2);
147328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(diffTypes($BT1{"Tid"}, $BT2{"Tid"}, $Level))
147348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different types
147358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
14738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
147418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
147428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
147438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            # TODO: arrays, etc.
147448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
14745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
147491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectTypeChange($$$$)
14750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
147511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Prefix, $Level) = @_;
14752dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Type1_Id or not $Type2_Id) {
14753dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return ();
14754dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LocalProblems = ();
1475662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1475762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
14758f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14759f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
1476086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
14761f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Base = ($Type1_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type1_Pure{"Tid"}, $TypeInfo{1}):get_BaseType($Type1_Id, 1);
14762f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Base = ($Type2_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type2_Pure{"Tid"}, $TypeInfo{2}):get_BaseType($Type2_Id, 2);
1476374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1476486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"})
1476586b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    {
1476686b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        if($Type1_Pure{"Name"} eq "__unknown__"
1476786b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type2_Pure{"Name"} eq "__unknown__"
1476886b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type1_Base{"Name"} eq "__unknown__"
1476986b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        or $Type2_Base{"Name"} eq "__unknown__")
1477086b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        { # Error ABI dump
1477186b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko            return ();
1477286b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko        }
1477386b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko    }
1477486b503bd85e3a0e8b32616d5af67c7d176a6263eAndrey Ponomarenko
1477562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type1_PLevel = get_PLevel($Type1_Id, 1);
1477662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type2_PLevel = get_PLevel($Type2_Id, 2);
14777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1{"Name"} or not $Type2{"Name"});
14778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Base{"Name"} or not $Type2_Base{"Name"});
14779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($Type1_PLevel eq "" or $Type2_PLevel eq "");
14780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Base{"Name"} ne $Type2_Base{"Name"}
14781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and ($Type1{"Name"} eq $Type2{"Name"} or ($Type1_PLevel>=1 and $Type1_PLevel==$Type2_PLevel
14782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Base{"Name"} ne "void" and $Type2_Base{"Name"} ne "void")))
14783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base type change
147849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Type1{"Name"} eq $Type2{"Name"})
147859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
147869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Type1{"Type"} eq "Typedef" and $Type2{"Type"} eq "Typedef")
147879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # will be reported in mergeTypes() as typedef problem
147889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return ();
147899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
147909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
147919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
147929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(%Typedef_1 and %Typedef_2)
147939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
147949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Typedef_1{"Name"} eq $Typedef_2{"Name"}
147959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef")
147969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # const Typedef
147979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    return ();
147989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
147999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
14800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1_Base{"Name"}!~/anon\-/ and $Type2_Base{"Name"}!~/anon\-/)
14802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
148031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
148048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} and $Type2_Base{"Size"}
148058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} ne $Type2_Base{"Size"})
14806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{$Prefix."_BaseType_And_Size"}}=(
14808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_Base{"Name"},
14809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_Base{"Name"},
14810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14811f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(diffTypes($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Level))
14816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # format change
14817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType_Format"}}=(
14818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14820f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14821f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(tNameLock($Type1_Base{"Tid"}, $Type2_Base{"Tid"}))
14824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType"}}=(
14826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14828f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14829f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type1{"Name"} ne $Type2{"Name"})
14835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # type change
14836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"}!~/anon\-/ and $Type2{"Name"}!~/anon\-/)
14837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14838f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Prefix eq "Return"
14839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1_Pure{"Name"} eq "void")
14840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_From_Void"}}=(
14842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2{"Name"},
14843f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Prefix eq "Return"
14846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2_Pure{"Name"} eq "void")
14847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_Became_Void"}}=(
14849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1{"Name"},
14850f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE);
14851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
14855dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} and $Type2{"Size"}
14856dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} ne $Type2{"Size"})
14857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_Type_And_Size"}}=(
14859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1{"Name"},
14860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2{"Name"},
14861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14862f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
14865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
148668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(diffTypes($Type1_Id, $Type2_Id, $Level))
14867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # format change
14868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type_Format"}}=(
14869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14871f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14872f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    elsif(tNameLock($Type1_Id, $Type2_Id))
14875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # FIXME: correct this condition
14876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type"}}=(
14877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14879f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14880f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_PLevel!=$Type2_PLevel)
14887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"} ne "void" and $Type1{"Name"} ne "..."
14889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Type2{"Name"} ne "void" and $Type2{"Name"} ne "...")
14890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
148911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
148921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
148931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$LocalProblems{$Prefix."_PointerLevel"}}=(
14894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_PLevel,
14895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_PLevel);
14896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
148971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
148981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
14899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Type2_PLevel>$Type1_PLevel)
14900fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
149011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Increased"}}=(
149021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
149031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
149041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
14906fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
149071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Decreased"}}=(
149081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
149091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
149101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14914ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    if($Type1_Pure{"Type"} eq "Array"
14915ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    and $Type1_Pure{"BaseType"})
14916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base_type[N] -> base_type[N]
14917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # base_type: older_structure -> typedef to newer_structure
149181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my %SubProblems = detectTypeChange($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Prefix, $Level);
14919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SubProblemType=~s/_Type/_BaseType/g;
14922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(defined $LocalProblems{$SubProblemType});
14923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Attr (keys(%{$SubProblems{$SubProblemType}})) {
14924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $LocalProblems{$SubProblemType}{$Attr} = $SubProblems{$SubProblemType}{$Attr};
14925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %LocalProblems;
14929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub tNameLock($$)
14932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Tid1, $Tid2) = @_;
149340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Changed = 0;
149350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(differentDumps("G"))
149360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different GCC versions
149370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Changed = 1;
149380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif(differentDumps("V"))
149400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different versions of ABI dumps
1494174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1494274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
149430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # latest names update
149440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.6: added restrict qualifier
149450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.13: added missed typedefs to qualified types
1494674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko          # 2.20: prefix for struct, union and enum types
149470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Changed = 1;
149480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN1 = $TypeInfo{1}{$Tid1}{"Name"};
149528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN2 = $TypeInfo{2}{$Tid2}{"Name"};
149538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149542b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT1 = $TypeInfo{1}{$Tid1}{"Type"};
149552b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT2 = $TypeInfo{2}{$Tid2}{"Type"};
149562b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
149570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Changed)
14958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
1495962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base1 = get_Type($Tid1, 1);
149600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base1{"Type"} and $Base1{"Type"} eq "Typedef") {
14961f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base1 = get_OneStep_BaseType($Base1{"Tid"}, $TypeInfo{1});
14962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1496362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base2 = get_Type($Tid2, 2);
149640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base2{"Type"} and $Base2{"Type"} eq "Typedef") {
14965f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base2 = get_OneStep_BaseType($Base2{"Tid"}, $TypeInfo{2});
14966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14967850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName1 = uncover_typedefs($Base1{"Name"}, 1);
14968850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName2 = uncover_typedefs($Base2{"Name"}, 2);
14969850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($BName1 eq $BName2)
14970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # equal base types
14971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
149730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1497462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1497562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.13"))
149760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # broken array names in ABI dumps < 2.13
149770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($TT1 eq "Array"
1497874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TT2 eq "Array") {
149790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 0;
149800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
149810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1498362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.6")
1498462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.6"))
149850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # added restrict attribute in 2.6
1498662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TN1!~/\brestrict\b/
1498774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TN2=~/\brestrict\b/) {
1498874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return 0;
1498974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1499074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1499174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1499274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1499374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
14994d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        { # added type prefix in 2.20
1499574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/
1499674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            or $TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
14997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
14998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
150018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    else
150028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
150038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct {...} type_t
150048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct type_t {...} type_t
150058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN1, " ".$TN2)!=-1)
150068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
150078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/) {
150088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
150098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
150108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
150118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN2, " ".$TN1)!=-1)
150128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
150138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
150148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
150158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
150168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
150172b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150182b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        if($TT1 eq "FuncPtr"
150192b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        and $TT2 eq "FuncPtr")
150202b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        {
150212b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN1_C = $TN1;
150222b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN2_C = $TN2;
150232b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150242b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN1_C=~s/\b(struct|union) //g;
150252b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN2_C=~s/\b(struct|union) //g;
150262b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
150272b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if($TN1_C eq $TN2_C) {
150282b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                return 0;
150292b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
150302b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
150318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
15032d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
15033d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my ($N1, $N2) = ($TN1, $TN2);
15034d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N1=~s/\b(struct|union) //g;
15035d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N2=~s/\b(struct|union) //g;
15036d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
15037d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($N1 eq $N2)
15038d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    { # QList<struct QUrl> and QList<QUrl>
15039d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        return 0;
15040d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
15041d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
15042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
15043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub differentDumps($)
15046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
150471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Check = $_[0];
15048989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(defined $Cache{"differentDumps"}{$Check}) {
15049989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $Cache{"differentDumps"}{$Check};
15050989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
15051dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UsedDump{1}{"V"} and $UsedDump{2}{"V"})
150521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
15053dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "G")
15054dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15055dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(getGccVersion(1) ne getGccVersion(2))
15056dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different GCC versions
15057989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15058dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
150591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15060dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "V")
15061dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15062dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(cmpVersions(formatVersion($UsedDump{1}{"V"}, 2),
15063dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            formatVersion($UsedDump{2}{"V"}, 2))!=0)
15064dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different dump versions (skip micro version)
15065989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15066dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
150671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15069989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($Cache{"differentDumps"}{$Check}=0);
15070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub formatVersion($$)
15073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # cut off version digits
15074dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($V, $Digits) = @_;
15075dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my @Elems = split(/\./, $V);
15076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(".", splice(@Elems, 0, $Digits));
15077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub htmlSpecChars($)
15080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
150825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
150835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
15084dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
15085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
15086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/</&lt;/g;
15087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\-\>/&#45;&gt;/g; # &minus;
15088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/>/&gt;/g;
150898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
150908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
15091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/ /&#160;/g; # &nbsp;
150928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/\@SP\@/ /g;
15093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\n/<br\/>/g;
15094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
15095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
15096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub xmlSpecChars($)
151005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
151015c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $Str = $_[0];
151025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
151035c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
151045c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
151055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151065c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
151075c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/</&lt;/g;
151085c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/>/&gt;/g;
151095c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151105c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
151115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
151125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return $Str;
151145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
151155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
1511601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub xmlSpecChars_R($)
1511701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
1511801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Str = $_[0];
1511901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Str) {
1512001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return $Str;
1512101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1512201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1512301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&amp;/&/g;
1512401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&lt;/</g;
1512501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&gt;/>/g;
1512601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1512701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&quot;/"/g;
1512801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&#39;/'/g;
1512901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1513001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return $Str;
1513101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1513201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
15133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub black_name($)
15134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
15136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<span class='iname_b'>".highLight_Signature($Name)."</span>";
15137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature($)
15140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 0, 0, 0);
15143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_Italic_Color($)
15146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 1, 1, 1);
15149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_symbol($)
15152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
15154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Spec, $Ver) = ($Symbol, "", "");
15155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Symbol=~/\A([^\@\$\?]+)([\@\$]+)([^\@\$]+)\Z/) {
15156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($Name, $Spec, $Ver) = ($1, $2, $3);
15157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $Spec, $Ver);
15159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_f_attrs($)
15162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~s/(\))((| (const volatile|const|volatile))(| \[static\]))\Z/$1/) {
15164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
15165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
15167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_PPos_Italic($$$$$)
15170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15171dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($FullSignature, $Param_Pos, $ItalicParams, $ColorParams, $ShowReturn) = @_;
15172dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Param_Pos = "" if(not defined $Param_Pos);
15173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Signature, $VersionSpec, $SymbolVersion) = separate_symbol($FullSignature);
15174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Return = "";
15175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowRetVal and $Signature=~s/([^:]):([^:].+?)\Z/$1/g) {
15176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Return = $2;
15177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $SCenter = find_center($Signature, "(");
15179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SCenter)
151801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # global data
15181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature = htmlSpecChars($Signature);
151828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature=~s!(\[data\])!<span class='attr'>$1</span>!g;
151831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= (($SymbolVersion)?"<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>":"");
15184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Return and $ShowReturn) {
151851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Signature;
15188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Begin, $End) = (substr($Signature, 0, $SCenter), "");
15190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Begin.=" " if($Begin!~/ \Z/);
15191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $End = cut_f_attrs($Signature);
15192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
1519307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Short, $Params) = split_Signature($Signature);
1519407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my @SParts = separate_Params($Params, 1, 1);
15195dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $Pos (0 .. $#SParts)
15196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15197dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Part = $SParts[$Pos];
15198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part=~s/\A\s+|\s+\Z//g;
15199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Part_Styled, $ParamName) = (htmlSpecChars($Part), "");
15200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Part=~/\([\*]+(\w+)\)/i) {
15201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;#func-ptr
15202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part=~/(\w+)[\,\)]*\Z/i) {
15204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;
15205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
152068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $ParamName)
152078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
15208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Parts, $Part_Styled);
15209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
15210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ItalicParams and not $TName_Tid{1}{$Part}
15212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $TName_Tid{2}{$Part})
15213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
152149e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            my $Style = "<i>$ParamName</i>";
152159e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
15216dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Param_Pos ne ""
15217dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            and $Pos==$Param_Pos) {
152189e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                $Style = "<span class=\'fp\'>$ParamName</span>";
15219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($ColorParams) {
152219e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                $Style = "<span class=\'color_p\'>$ParamName</span>";
15222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
152239e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
152249e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            $Part_Styled=~s!(\W)$ParamName([\,\)]|\Z)!$1$Style$2!ig;
15225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part_Styled=~s/,(\w)/, $1/g;
15227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Parts, $Part_Styled);
15228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Parts)
15230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (0 .. $#Parts)
15232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Num==$#Parts)
15234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # add ")" to the last parameter
15235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]." )</span>";
15236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif(length($Parts[$Num])<=45) {
15238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]."</span>";
15239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
152411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;".join(" ", @Parts)."</span>".$End;
15242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
152441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;)</span>".$End;
15245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Return and $ShowReturn) {
152471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
152491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!\[\]![&#160;]!g;
152501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!operator=!operator&#160;=!g;
152518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Signature=~s!(\[in-charge\]|\[not-in-charge\]|\[in-charge-deleting\]|\[static\])!<span class='attr'>$1</span>!g;
152528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($SymbolVersion) {
152538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= "<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>";
152548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
152558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return $Signature;
15256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1525807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub split_Signature($)
15259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1526007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my $Signature = $_[0];
1526107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1526207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
1526307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E\(//g;
1526407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        cut_f_attrs($Signature);
1526507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\)\Z//;
1526607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return ($ShortName, $Signature);
1526707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
1526807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1526907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # error
1527007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    return ($Signature, "");
15271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1527307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub separate_Params($$$)
15274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1527507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Params, $Comma, $Sp) = @_;
15276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
152771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
152781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Part = 0;
15279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Params) - 1)
15280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
152811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $S = substr($Params, $Pos, 1);
152821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $B{$S}) {
1528307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $B{$S} += 1;
152841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
152851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($S eq "," and
152861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $B{"("}==$B{")"} and $B{"<"}==$B{">"})
15287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
152881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Comma)
152891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # include comma
152901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Parts[$Part] .= $S;
15291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
152921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Part += 1;
15293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
152951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Parts[$Part] .= $S;
15296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1529807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(not $Sp)
1529907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    { # remove spaces
1530007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        foreach (@Parts)
1530107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1530207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/\A //g;
1530307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/ \Z//g;
1530407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1530507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
15306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Parts;
15307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
153091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub find_center($$)
15310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Sign, $Target) = @_;
153121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
15313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Center = 0;
153141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Sign=~s/(operator([^\w\s\(\)]+|\(\)))//g)
153151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # operators
15316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=length($1);
15317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Sign)-1)
15319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $S = substr($Sign, $Pos, 1);
15321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S eq $Target)
15322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($B{"("}==$B{")"}
15324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $B{"<"}==$B{">"}) {
15325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Center;
15326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $B{$S}) {
15329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $B{$S}+=1;
15330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=1;
15332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
15334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub appendFile($$)
15337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">>", $Path) || die ("can't open file \'$Path\': $!\n");
15344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeFile($$)
15349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n");
15356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readFile($)
15361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
153641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    local $/ = undef;
15366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = <FILE>;
15367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15368850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Path!~/\.(tu|class|abi)\Z/) {
15369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\r/\n/g;
15370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
15372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_filename($)
15375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than basename() from File::Basename module
15376850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_filename"}{$_[0]}) {
15377850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_filename"}{$_[0]};
15378850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
153791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) {
15380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_filename"}{$_[0]}=$1);
15381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15382850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_filename"}{$_[0]}="");
15383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dirname($)
15386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than dirname() from File::Basename module
15387850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_dirname"}{$_[0]}) {
15388850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_dirname"}{$_[0]};
15389850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
153901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) {
15391850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_dirname"}{$_[0]}=$1);
15392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15393850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_dirname"}{$_[0]}="");
15394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_path($) {
15397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (get_dirname($_[0]), get_filename($_[0]));
15398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub esc($)
15401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
15403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/([()\[\]{}$ &'"`;,<>\+])/\\$1/g;
15404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLineNum($$)
15408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Num) = @_;
15410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
154111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (1 ... $Num) {
15413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        <FILE>;
15414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Line = <FILE>;
15416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Line;
15418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub readAttributes($$)
15421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
154220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Path, $Num) = @_;
15423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -f $Path);
15424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Attributes = ();
15425850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(readLineNum($Path, $Num)=~/<!--\s+(.+)\s+-->/)
15426850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15427850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $AttrVal (split(/;/, $1))
15428850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($AttrVal=~/(.+):(.+)/)
15430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
15432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Attributes{$Name} = $Value;
15433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Attributes;
15437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_abs($) {
15440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($_[0]=~/\A(\/|\w+:[\/\\])/);
15441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_abs_path($)
15444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # abs_path() should NOT be called for absolute inputs
15445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # because it can change them
15446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not is_abs($Path)) {
15448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = abs_path($Path);
15449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
15451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_OSgroup()
15454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15455f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $Config{"osname"};
15456f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($N=~/macos|darwin|rhapsody/i) {
15457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "macos";
15458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15459f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/freebsd|openbsd|netbsd/i) {
15460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "bsd";
15461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15462f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/haiku|beos/i) {
15463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "beos";
15464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15465f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/symbian|epoc/i) {
15466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "symbian";
15467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15468f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/win/i) {
15469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "windows";
15470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
15472f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return $N;
15473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getGccVersion($)
15477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GCC_VERSION{$LibVersion})
15480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $GCC_VERSION{$LibVersion};
15482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccVersion = get_dumpversion($GCC_PATH); # host version
15488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GccVersion) {
15489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccVersion;
15492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showArch($)
15495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = $_[0];
15497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch eq "arm"
15498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Arch eq "mips") {
15499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return uc($Arch);
15500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArch($)
15505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1550754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1550854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if($TargetArch) {
1550954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        return $TargetArch;
1551054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
15511d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    elsif($CPU_ARCH{$LibVersion})
155121fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    { # dump
15513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $CPU_ARCH{$LibVersion};
15514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1551954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
15520d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return getArch_GCC($LibVersion);
15521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1552352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkosub get_Report_Title($)
15524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
155251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
1552652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ArchInfo = " on <span style='color:Blue;'>".showArch(getArch(1))."</span>";
155281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getArch(1) ne getArch(2)
155291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or getArch(1) eq "unknown"
155301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
15531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # don't show architecture in the header
15532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ArchInfo="";
15533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1553452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $Title = "";
155351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Source") {
1553652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Source compatibility";
155371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Binary") {
1553952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Binary compatibility";
155401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
1554252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "API compatibility";
155431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1554452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1554515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko    my $V1 = $Descriptor{1}{"Version"};
1554615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko    my $V2 = $Descriptor{2}{"Version"};
1554715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1554852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($UsedDump{1}{"DWARF"} and $UsedDump{2}{"DWARF"})
1554952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1555052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M1 = $UsedDump{1}{"M"};
1555152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M2 = $UsedDump{2}{"M"};
1555252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1555315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        my $M1S = $M1;
1555415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        my $M2S = $M2;
1555515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1555615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $M1S=~s/(\.so|\.ko)\..+/$1/ig;
1555715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $M2S=~s/(\.so|\.ko)\..+/$1/ig;
1555815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1555915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if($M1S eq $M2S
1556015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        and $V1 ne "X" and $V2 ne "Y")
1556152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1556215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " report for the <span style='color:Blue;'>$M1S</span> $TargetComponent";
1556315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " between <span style='color:Red;'>".$V1."</span> and <span style='color:Red;'>".$V2."</span> versions";
1556452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1556552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        else
1556652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1556715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " report between <span style='color:Blue;'>$M1</span> (<span style='color:Red;'>".$V1."</span>)";
1556815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Title .= " and <span style='color:Blue;'>$M2</span> (<span style='color:Red;'>".$V2."</span>) objects";
1556952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1557052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1557152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    else
1557252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1557314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $Title .= " report for the <span style='color:Blue;'>$TargetTitle</span> $TargetComponent";
1557415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $Title .= " between <span style='color:Red;'>".$V1."</span> and <span style='color:Red;'>".$V2."</span> versions";
1557552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1557652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1557752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title .= $ArchInfo;
1557852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath) {
1558001e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko        $Title .= " (relating to the portability of application <span style='color:Blue;'>".get_filename($AppPath)."</span>)";
15581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1558252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title = "<h1>".$Title."</h1>\n";
1558352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    return $Title;
15584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15586ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkosub get_CheckedHeaders($)
15587ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko{
15588ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my $LibVersion = $_[0];
15589ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15590ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my @Headers = ();
15591ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15592ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
15593ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
15594ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $File = get_filename($Path);
155951fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
15596ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not is_target_header($File, $LibVersion)) {
15597ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15598ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15599ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15600ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(skipHeader($File, $LibVersion)) {
15601ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15602ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15603ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15604ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        push(@Headers, $Path);
15605ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
15606ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15607ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    return @Headers;
15608ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko}
15609ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SourceInfo()
15611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($CheckedHeaders, $CheckedSources, $CheckedLibs) = ("", "");
15613ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15614ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Headers = get_CheckedHeaders(1))
15615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15616ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders = "<a name='Headers'></a><h2>Header Files (".($#Headers+1).")</h2><hr/>\n";
15617ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<div class='h_list'>\n";
15618ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
1561962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
15620ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Headers{1}{$Header_Path}{"Identity"};
15621ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15622ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15623ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedHeaders .= $Name.$Comment."<br/>\n";
15624fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15625ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "</div>\n";
15626ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<br/>$TOP_REF<br/>\n";
15627ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15628ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15629ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Sources = keys(%{$Registered_Sources{1}}))
15630ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15631ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources = "<a name='Sources'></a><h2>Source Files (".($#Sources+1).")</h2><hr/>\n";
15632ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<div class='h_list'>\n";
15633ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15634fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15635ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Sources{1}{$Header_Path}{"Identity"};
15636ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15637ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15638ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedSources .= $Name.$Comment."<br/>\n";
1563962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
15640ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "</div>\n";
15641ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<br/>$TOP_REF<br/>\n";
15642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15643ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1564462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckHeadersOnly)
15645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $CheckedLibs = "<a name='Libs'></a><h2>".get_ObjTitle()." (".keys(%{$Library_Symbol{1}}).")</h2><hr/>\n";
1564762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<div class='lib_list'>\n";
1564862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
1564962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
156508a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            # $Library .= " (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
1565162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $CheckedLibs .= $Library."<br/>\n";
1565262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1565362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "</div>\n";
1565462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<br/>$TOP_REF<br/>\n";
15655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15656ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $CheckedHeaders.$CheckedSources.$CheckedLibs;
15658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
15659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub get_ObjTitle()
15661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
15662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"}) {
15663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return "Objects";
15664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else {
15666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return ucfirst($SLIB_TYPE)." Libraries";
15667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TypeProblems_Count($$$)
15671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeChanges, $TargetPriority, $Level) = @_;
15673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Type_Problems_Count = 0;
15674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (sort keys(%{$TypeChanges}))
15675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
15677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges->{$Type_Name}}))
15678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges->{$Type_Name}{$Kind}}))
15680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges->{$Type_Name}{$Kind}{$Location}{"Target"};
156822489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
156832489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next if($Severity ne $TargetPriority);
15684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Kinds_Target{$Kind}{$Target}) {
15685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
156872489ef88760861175102e4508089608391beead3Andrey Ponomarenko
156882489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target})
156892489ef88760861175102e4508089608391beead3Andrey Ponomarenko                {
156902489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
156912489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    { # select a problem with the highest priority
156922489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        next;
156932489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    }
15694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
15696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Type_Problems_Count += 1;
15697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Type_Problems_Count;
15701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Summary($)
15704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
157051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
157061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Added, $Removed, $I_Problems_High, $I_Problems_Medium, $I_Problems_Low, $T_Problems_High,
157078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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);
157081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %{$RESULT{$Level}} = (
157091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Problems"=>0,
157101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Warnings"=>0,
157111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Affected"=>0 );
15712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check rules
157131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
157151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
15718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unknown rule
15719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
15720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # only one warning
15721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
15722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
15723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
157241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                delete($CompatProblems{$Level}{$Interface}{$Kind});
15725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
157288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (sort keys(%{$CompatProblems_Constants{$Level}}))
157298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
157308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
157318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
157328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
157338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # unknown rule
157348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
157358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # only one warning
157368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
157378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
157388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
157398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($CompatProblems_Constants{$Level}{$Constant}{$Kind});
157408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
157418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
157428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
157431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
157451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
15746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols")
15748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
157491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
157512489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
157521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Kind eq "Added_Symbol") {
15753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added += 1;
15754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
157551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($Kind eq "Removed_Symbol")
15756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed += 1;
157582489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = $Severity;
15759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
15761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
157622489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity eq "Safe") {
15763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Other += 1;
15764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157652489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "High") {
15766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_High += 1;
15767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157682489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Medium") {
15769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Medium += 1;
15770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157712489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Low") {
15772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Low += 1;
15773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157742489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if(($Severity ne "Low" or $StrictCompat)
157752489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        and $Severity ne "Safe") {
157762489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeChanges = ();
157841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
157861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
15789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15790f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
157921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Type_Name = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
157931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
157942489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
15795f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target};
15796f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
157972489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($MaxSeverity and $Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
15798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # select a problem with the highest priority
15799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
15800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15801f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
158022489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(($Severity ne "Low" or $StrictCompat)
158032489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    and $Severity ne "Safe")
15804f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
15805f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if(defined $TotalAffected{$Level}{$Interface})
15806f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
158072489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            if($Severity_Val{$Severity}>$Severity_Val{$TotalAffected{$Level}{$Interface}}) {
158082489ef88760861175102e4508089608391beead3Andrey Ponomarenko                                $TotalAffected{$Level}{$Interface} = $Severity;
15809f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            }
15810f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15811f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        else {
158122489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15813f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15814f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15815f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15816f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeChanges{$Type_Name}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
15817f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15818f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($MaxSeverity)
15819f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
158202489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$Severity}>$Severity_Val{$MaxSeverity}) {
158212489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15822f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15823f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15824f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    else {
158252489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
158311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_High = get_TypeProblems_Count(\%TypeChanges, "High", $Level);
15833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Medium = get_TypeProblems_Count(\%TypeChanges, "Medium", $Level);
15834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Low = get_TypeProblems_Count(\%TypeChanges, "Low", $Level);
15835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Other = get_TypeProblems_Count(\%TypeChanges, "Safe", $Level);
158361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15837f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    %TypeChanges = (); # free memory
15838f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15839ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # changed and removed public symbols
15840ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $SCount = keys(%{$CheckedSymbols{$Level}});
15841ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($ExtendedCheck)
15842ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # don't count external_func_0 for constants
15843ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $SCount-=1;
15844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15845ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($SCount)
15846ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15847ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my %Weight = (
15848ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "High" => 100,
15849ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Medium" => 50,
15850ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Low" => 25
15851ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        );
15852ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach (keys(%{$TotalAffected{$Level}})) {
15853ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $RESULT{$Level}{"Affected"}+=$Weight{$TotalAffected{$Level}{$_}};
15854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15855ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = $RESULT{$Level}{"Affected"}/$SCount;
15856ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15857ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
15858ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 0;
15859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15860ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
158611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Affected"} = show_number($RESULT{$Level}{"Affected"});
158621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($RESULT{$Level}{"Affected"}>=100) {
158631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 100;
15864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15866850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $Removed;
15867850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_High + $I_Problems_High;
158681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_Medium + $I_Problems_Medium;
15869850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($StrictCompat) {
15870850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Problems"} += $T_Problems_Low + $I_Problems_Low;
15871850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15872850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15873850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Warnings"} += $T_Problems_Low + $I_Problems_Low;
15874850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
158771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
158788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
15879850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15880f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
158818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Severity eq "Safe")
158828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
158838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Other+=1;
15884850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
158858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            elsif($Severity eq "Low")
158868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
158878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Problems_Low+=1;
15888850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
158891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
158908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
158918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
158928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($C_Problems_Low)
158938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
158948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($StrictCompat) {
158958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += $C_Problems_Low;
158968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
158978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else {
158988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += $C_Problems_Low;
158991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
159001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
15901850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($RESULT{$Level}{"Problems"}
15902850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    and $RESULT{$Level}{"Affected"}) {
15903850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "incompatible";
15904850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15905850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15906850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "compatible";
159071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
159081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
159091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $TotalTypes = keys(%{$CheckedTypes{$Level}});
159101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $TotalTypes)
159111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # list all the types
15912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TotalTypes = keys(%{$TName_Tid{1}});
15913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Arch1, $Arch2) = (getArch(1), getArch(2));
15916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($GccV1, $GccV2) = (getGccVersion(1), getGccVersion(2));
15917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TestInfo, $TestResults, $Problem_Summary) = ();
15919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
15921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
15922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <library>$TargetLibraryName</library>\n";
15924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version1>\n";
15925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{1}{"Version"}."</number>\n";
15926d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch1</arch>\n";
15927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV1</gcc>\n";
15928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version1>\n";
15929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version2>\n";
15931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{2}{"Version"}."</number>\n";
15932d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch2</arch>\n";
15933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV2</gcc>\n";
15934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version2>\n";
15935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<test_info>\n".$TestInfo."</test_info>\n\n";
15936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15938fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15940fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <headers>\n";
15941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15942fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15943fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Name}{"Identity"};
15944fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </headers>\n";
15948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15949fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15950fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15951fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15952fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <sources>\n";
15953fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15955fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Name}{"Identity"};
15956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </sources>\n";
15960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <libs>\n";
15963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
15964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
159658a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            # $Library .= " (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
15966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestResults .= "    <name>$Library</name>\n";
15967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  </libs>\n";
15969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1597062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "  <symbols>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))."</symbols>\n";
15971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <types>".$TotalTypes."</types>\n";
15972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <verdict>".$RESULT{$Level}{"Verdict"}."</verdict>\n";
159741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <affected>".$RESULT{$Level}{"Affected"}."</affected>\n";
15975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<test_results>\n".$TestResults."</test_results>\n\n";
15976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <added_symbols>".$Added."</added_symbols>\n";
15979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <removed_symbols>".$Removed."</removed_symbols>\n";
15980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_types>\n";
15982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$T_Problems_High</high>\n";
15983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$T_Problems_Medium</medium>\n";
15984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$T_Problems_Low</low>\n";
15985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <safe>$T_Other</safe>\n";
15986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_types>\n";
15987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_symbols>\n";
15989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$I_Problems_High</high>\n";
15990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$I_Problems_Medium</medium>\n";
15991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$I_Problems_Low</low>\n";
159921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <safe>$I_Other</safe>\n";
15993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_symbols>\n";
15994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_constants>\n";
159961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <low>$C_Problems_Low</low>\n";
15997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_constants>\n";
1599852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<problem_summary>\n".$Problem_Summary."</problem_summary>\n\n";
16000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, "");
16002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
16006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<h2>Test Info</h2><hr/>\n";
160071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestInfo .= "<table class='summary'>\n";
1600815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko
1600915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if($TargetComponent eq "library") {
1601015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $TestInfo .= "<tr><th>Library Name</th><td>$TargetTitle</td></tr>\n";
1601115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
1601215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        else {
1601315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $TestInfo .= "<tr><th>Module Name</th><td>$TargetTitle</td></tr>\n";
1601415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
16015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@VInf1, @VInf2, $AddTestInfo) = ();
16017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch1 ne "unknown"
16018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Arch2 ne "unknown")
16019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # CPU arch
16020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Arch1 eq $Arch2)
16021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
160221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $AddTestInfo .= "<tr><th>CPU Type</th><td>".showArch($Arch1)."</td></tr>\n";
16023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
16026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, showArch($Arch1));
16027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, showArch($Arch2));
16028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GccV1 ne "unknown"
16031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $GccV2 ne "unknown"
16032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $OStarget ne "windows")
16033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # GCC version
16034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GccV1 eq $GccV2)
16035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
16036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AddTestInfo .= "<tr><th>GCC Version</th><td>$GccV1</td></tr>\n";
16037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
16040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, "gcc ".$GccV1);
16041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, "gcc ".$GccV2);
16042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # show long version names with GCC version and CPU architecture name (if different)
16045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #1</th><td>".$Descriptor{1}{"Version"}.(@VInf1?" (".join(", ", reverse(@VInf1)).")":"")."</td></tr>\n";
16046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #2</th><td>".$Descriptor{2}{"Version"}.(@VInf2?" (".join(", ", reverse(@VInf2)).")":"")."</td></tr>\n";
16047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= $AddTestInfo;
16048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($COMMON_LANGUAGE{1}) {
16049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #    $TestInfo .= "<tr><th>Language</th><td>".$COMMON_LANGUAGE{1}."</td></tr>\n";
16050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
16051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck) {
16052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestInfo .= "<tr><th>Mode</th><td>Extended</td></tr>\n";
16053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
160541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
160551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary") {
160571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>\n"; # Run-time
160581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source") {
160601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>\n"; # Build-time
160611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "</table>\n";
16064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
16066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<h2>Test Results</h2><hr/>\n";
160671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "<table class='summary'>";
16068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160696ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        if(my @Headers = get_CheckedHeaders(1))
16070fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16071fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Headers_Link = "<a href='#Headers' style='color:Blue;'>".($#Headers + 1)."</a>";
16072fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>".$Headers_Link."</td></tr>\n";
16073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
16075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
16076fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Src_Link = "<a href='#Sources' style='color:Blue;'>".($#Sources + 1)."</a>";
16078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Source Files</th><td>".$Src_Link."</td></tr>\n";
16079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck)
16082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Libs_Link = "0";
16084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Libs_Link = "<a href='#Libs' style='color:Blue;'>".keys(%{$Library_Symbol{1}})."</a>" if(keys(%{$Library_Symbol{1}})>0);
16085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total ".get_ObjTitle()."</th><td>".($CheckHeadersOnly?"0&#160;(not&#160;analyzed)":$Libs_Link)."</td></tr>\n";
16086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1608862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "<tr><th>Total Symbols / Types</th><td>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))." / ".$TotalTypes."</td></tr>\n";
16089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16090850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $META_DATA = "verdict:".$RESULT{$Level}{"Verdict"}.";";
160911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport) {
160921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $META_DATA = "kind:".lc($Level).";".$META_DATA;
160931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
160941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "<tr><th>Verdict</th>";
16095850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($RESULT{$Level}{"Verdict"} eq "incompatible") {
160961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Red;'><b>Incompatible<br/>(".$RESULT{$Level}{"Affected"}."%)</b></span></td>";
160971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
160981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else {
160991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Green;'><b>Compatible</b></span></td>";
161001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
161011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "</tr>\n";
16102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "</table>\n";
16103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "affected:".$RESULT{$Level}{"Affected"}.";";# in percents
16105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
16106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<h2>Problem Summary</h2><hr/>\n";
161071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "<table class='summary'>";
16108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "<tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr>";
16109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Link = "0";
161111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Added>0)
161121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
161141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#".$Level."_Added' style='color:Blue;'>$Added</a>";
161151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
161171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#Added' style='color:Blue;'>$Added</a>";
161181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "added:$Added;";
161211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Added Symbols</th><td>-</td><td".getStyle("I", "A", $Added).">$Added_Link</td></tr>\n";
16122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Removed_Link = "0";
161241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Removed>0)
161251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
161271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#".$Level."_Removed' style='color:Blue;'>$Removed</a>"
161281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
161301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#Removed' style='color:Blue;'>$Removed</a>"
161311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "removed:$Removed;";
161341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Removed Symbols</th>";
161351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "R", $Removed).">$Removed_Link</td></tr>\n";
16136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TH_Link = "0";
161381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TH_Link = "<a href='#".get_Anchor("Type", $Level, "High")."' style='color:Blue;'>$T_Problems_High</a>" if($T_Problems_High>0);
16139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_high:$T_Problems_High;";
161401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Data Types</th>";
161411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("T", "H", $T_Problems_High).">$TH_Link</td></tr>\n";
16142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TM_Link = "0";
161441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TM_Link = "<a href='#".get_Anchor("Type", $Level, "Medium")."' style='color:Blue;'>$T_Problems_Medium</a>" if($T_Problems_Medium>0);
16145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_medium:$T_Problems_Medium;";
161461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("T", "M", $T_Problems_Medium).">$TM_Link</td></tr>\n";
16147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TL_Link = "0";
161491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TL_Link = "<a href='#".get_Anchor("Type", $Level, "Low")."' style='color:Blue;'>$T_Problems_Low</a>" if($T_Problems_Low>0);
16150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_low:$T_Problems_Low;";
161511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("T", "L", $T_Problems_Low).">$TL_Link</td></tr>\n";
16152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IH_Link = "0";
161541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IH_Link = "<a href='#".get_Anchor("Symbol", $Level, "High")."' style='color:Blue;'>$I_Problems_High</a>" if($I_Problems_High>0);
16155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_high:$I_Problems_High;";
161561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Symbols</th>";
161571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "H", $I_Problems_High).">$IH_Link</td></tr>\n";
16158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IM_Link = "0";
161601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IM_Link = "<a href='#".get_Anchor("Symbol", $Level, "Medium")."' style='color:Blue;'>$I_Problems_Medium</a>" if($I_Problems_Medium>0);
16161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_medium:$I_Problems_Medium;";
161621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("I", "M", $I_Problems_Medium).">$IM_Link</td></tr>\n";
16163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IL_Link = "0";
161651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IL_Link = "<a href='#".get_Anchor("Symbol", $Level, "Low")."' style='color:Blue;'>$I_Problems_Low</a>" if($I_Problems_Low>0);
16166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_low:$I_Problems_Low;";
161671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("I", "L", $I_Problems_Low).">$IL_Link</td></tr>\n";
16168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ChangedConstants_Link = "0";
161708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}}) and $C_Problems_Low) {
161718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedConstants_Link = "<a href='#".get_Anchor("Constant", $Level, "Low")."' style='color:Blue;'>$C_Problems_Low</a>";
16172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
161731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "changed_constants:$C_Problems_Low;";
161741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
16175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Safe Changes
16177ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($T_Other)
161781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $TS_Link = "<a href='#".get_Anchor("Type", $Level, "Safe")."' style='color:Blue;'>$T_Other</a>";
161801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
161811fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "type_changes_other:$T_Other;";
161821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
161831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16184ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($I_Other)
161851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $IS_Link = "<a href='#".get_Anchor("Symbol", $Level, "Safe")."' style='color:Blue;'>$I_Other</a>";
161871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Symbols</th><td>-</td><td".getStyle("I", "S", $I_Other).">$IS_Link</td></tr>\n";
161881fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "interface_changes_other:$I_Other;";
16189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16191ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($C_Other)
161928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
161938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $CS_Link = "<a href='#".get_Anchor("Constant", $Level, "Safe")."' style='color:Blue;'>$C_Other</a>";
161948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Constants</th><td>-</td><td".getStyle("C", "S", $C_Other).">$CS_Link</td></tr>\n";
161951fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $META_DATA .= "constant_changes_other:$C_Other;";
161968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
161978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "tool_version:$TOOL_VERSION";
16199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "</table>\n";
162001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # $TestInfo = getLegend().$TestInfo;
16201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, $META_DATA);
16202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getStyle($$$)
162061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
162071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Subj, $Act, $Num) = @_;
162081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Style = (
162091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "A"=>"new",
162101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "R"=>"failed",
162111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "S"=>"passed",
162121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "L"=>"warning",
162131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "M"=>"failed",
162141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "H"=>"failed"
162151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
162161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Num>0) {
162171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return " class='".$Style{$Act}."'";
162181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
162191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "";
162201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
162211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
16222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub show_number($)
16223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($_[0])
16225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
162261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Num = cut_off_number($_[0], 2, 0);
162271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Num eq "0")
162281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
162291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $P (3 .. 7)
162301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
162311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Num = cut_off_number($_[0], $P, 1);
162321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($Num ne "0") {
162331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    last;
162341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
162351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
16236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num eq "0") {
16238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Num = $_[0];
16239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Num;
16241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0];
16243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub cut_off_number($$$)
16246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($num, $digs_to_cut, $z) = @_;
16248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($num!~/\./)
16249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $num .= ".";
16251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut-1) {
16252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\.(.+)\Z/ and length($1)<$digs_to_cut-1)
16256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut - 1 - length($1)) {
16258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\d+\.(\d){$digs_to_cut,}/) {
16262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      $num=sprintf("%.".($digs_to_cut-1)."f", $num);
16263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $num=~s/\.[0]+\Z//g;
162651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($z) {
162661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $num=~s/(\.[1-9]+)[0]+\Z/$1/g;
162671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $num;
16269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub get_Report_ChangedConstants($$)
16272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
162741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_CONSTANTS = "";
162758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
162761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
162778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
162788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
162798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Header = $Constants{1}{$Constant}{"Header"};
162808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Header)
162818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # added
162828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Header = $Constants{2}{$Constant}{"Header"}
162838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
162848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
162858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
162868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
162878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind}) {
162888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
162898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
16290f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($TargetSeverity ne $CompatRules{$Level}{$Kind}{"Severity"}) {
162918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
162928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
162938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ReportMap{$Header}{$Constant}{$Kind} = 1;
162948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
162951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
162991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "  <header name=\"$HeaderName\">\n";
163021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    <constant name=\"$Constant\">\n";
163058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
163068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
163078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = $CompatRules{$Level}{$Kind}{"Change"};
163088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
163098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16310fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
163118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      <problem id=\"$Kind\">\n";
163128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <change".getXmlParams($Change, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Change</change>\n";
163138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <effect".getXmlParams($Effect, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Effect</effect>\n";
16314d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    if($Overcome) {
16315d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        $CHANGED_CONSTANTS .= "        <overcome".getXmlParams($Overcome, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Overcome</overcome>\n";
16316d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    }
163178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      </problem>\n";
163188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
16319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    </constant>\n";
16320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "    </header>\n";
16322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CHANGED_CONSTANTS = "<problems_with_constants severity=\"Low\">\n".$CHANGED_CONSTANTS."</problems_with_constants>\n\n";
16324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Number = 0;
163281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<span class='h_name'>$HeaderName</span><br/>\n";
163318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
163338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $Report = "";
163348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
163358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
163368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
163378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, $CompatProblems_Constants{$Level}{$Constant}{$Kind});
163388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
163399e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                    $Report .= "<tr>\n<th>1</th>\n<td>".$Change."</td>\n<td>$Effect</td>\n</tr>\n";
163408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Number += 1;
163418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
163428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Report)
163438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
1634415bfdc281d18ec26a6a056ed45d641a885716165Andrey 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";
163459e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                    $Report = $ContentSpanStart."<span class='ext'>[+]</span> ".$Constant.$ContentSpanEnd."<br/>\n".$Report;
163468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = insertIDs($Report);
163478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
163488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $CHANGED_CONSTANTS .= $Report;
16349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<br/>\n";
16351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
163521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CHANGED_CONSTANTS)
163531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
163548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Title = "Problems with Constants, $TargetSeverity Severity";
163558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity eq "Safe")
163568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # Safe Changes
163578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Title = "Other Changes in Constants";
163581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
163598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CHANGED_CONSTANTS = "<a name='".get_Anchor("Constant", $Level, $TargetSeverity)."'></a><h2>$Title ($Number)</h2><hr/>\n".$CHANGED_CONSTANTS.$TOP_REF."<br/>\n";
16360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_CONSTANTS;
16363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getTitle($$$)
163661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
163671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Header, $Library, $NameSpace) = @_;
163681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Title = "";
163698a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
163708a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    # if($Library and $Library!~/\.\w+\Z/) {
163718a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    #     $Library .= " (.$LIB_EXT)";
163728a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    # }
163738a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
163741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Header and $Library)
163751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
163761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span>";
163771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= ", <span class='lib_name'>$Library</span><br/>\n";
163781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Library) {
163801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='lib_name'>$Library</span><br/>\n";
163811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Header) {
163831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span><br/>\n";
163841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($NameSpace) {
1638674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Title .= "<span class='ns'>namespace <b>$NameSpace</b></span><br/>\n";
163871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return $Title;
163891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
163901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Added($)
16392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
163931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
163941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ADDED_INTERFACES = "";
163951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
163961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
163981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
16399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Added_Symbol")
16401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $HeaderName = $CompleteSignature{2}{$Interface}{"Header"};
16403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $DyLib = $Symbol_Library{2}{$Interface};
164041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
164051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
164061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
164071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
164081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
164141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
164171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    <library name=\"$DyLib\">\n";
164201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ADDED_INTERFACES .= "      <name>$Interface</name>\n";
16422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    </library>\n";
16424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  </header>\n";
16426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ADDED_INTERFACES = "<added_symbols>\n".$ADDED_INTERFACES."</added_symbols>\n\n";
16428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Number = 0;
164321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
164361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
164371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1643874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
164401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
164421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
164431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 2)) cmp lc(get_Signature($b, 2))} keys(%{$NameSpaceSymbols{$NameSpace}});
16444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Interface (@SortedInterfaces)
16445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added_Number += 1;
16447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Signature = get_Signature($Interface, 2);
16448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1644962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
164519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Interface=~/\A(_Z|\?)/)
164529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
1645415bfdc281d18ec26a6a056ed45d641a885716165Andrey 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");
16455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
164571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
164609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        else
164619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
164631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
164661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
164701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= "<br/>\n";
16471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
164741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ADDED_INTERFACES)
164751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
164761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Added'></a>";
164771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
164781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Added'></a>";
164791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
164801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ADDED_INTERFACES = $Anchor."<h2>Added Symbols ($Added_Number)</h2><hr/>\n".$ADDED_INTERFACES.$TOP_REF."<br/>\n";
16481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ADDED_INTERFACES;
16484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Removed($)
16487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
164881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
164891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $REMOVED_INTERFACES = "";
164901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
16491850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16493850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Removed_Symbol")
16496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16497850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16498850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
164991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
165001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
165011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
165021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
16503850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
165091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
165121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    <library name=\"$DyLib\">\n";
16515850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16516850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $REMOVED_INTERFACES .= "      <name>$Symbol</name>\n";
16517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    </library>\n";
16519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  </header>\n";
16521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $REMOVED_INTERFACES = "<removed_symbols>\n".$REMOVED_INTERFACES."</removed_symbols>\n\n";
16523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
165261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Removed_Number = 0;
165271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
165281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
165291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
165301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
165311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
165321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1653374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 1)}{$Interface} = 1;
16534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
165371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $REMOVED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
165381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16539850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed_Number += 1;
16542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $SubReport = "";
16543850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
16544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1654562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16547850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if($Symbol=~/\A(_Z|\?)/)
165481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
1655015bfdc281d18ec26a6a056ed45d641a885716165Andrey 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");
16551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16553850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
165561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
165571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
165591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16562850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "<br/>\n";
16568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($REMOVED_INTERFACES)
165711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
165721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Removed'></a><a name='Withdrawn'></a>";
165731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
165741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Removed'></a><a name='".$Level."_Withdrawn'></a>";
165751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
165761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $REMOVED_INTERFACES = $Anchor."<h2>Removed Symbols ($Removed_Number)</h2><hr/>\n".$REMOVED_INTERFACES.$TOP_REF."<br/>\n";
16577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $REMOVED_INTERFACES;
16580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getXmlParams($$)
16583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Problem) = @_;
16585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %XMLparams = ();
16587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Content=~/\Q$Macro\E/) {
16591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $XMLparams{lc($Attr)} = $Problem->{$Attr};
16592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @PString = ();
16595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $P (sort {$b cmp $a} keys(%XMLparams)) {
165965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        push(@PString, $P."=\"".xmlSpecChars($XMLparams{$P})."\"");
16597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@PString) {
16599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return " ".join(" ", @PString);
16600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
16603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMarkup($)
16607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = $_[0];
16609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # auto-markup
16610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\n[ ]*//; # spaces
16611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(\@\w+\s*\(\@\w+\))!<nowrap>$1</nowrap>!g; # @old_type (@old_size)
16612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(... \(\w+\))!<nowrap><b>$1</b></nowrap>!g; # ... (va_list)
166130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!<nowrap>(.+?)</nowrap>!<span class='nowrap'>$1</span>!g;
16614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!([2-9]\))!<br/>$1!g; # 1), 2), ...
16615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/\ANOTE:/)
16616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # notes
16617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<b>$1</b>:!g;
16618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<br/><b>$1</b>:!g;
16621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s! (out)-! <b>$1</b>-!g; # out-parameters
16623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Keywords = (
16624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "void",
16625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "const",
16626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "static",
16627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "restrict",
16628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "volatile",
16629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "register",
166300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        "virtual"
16631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
16632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MKeys = join("|", @Keywords);
16633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Keywords) {
16634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MKeys .= "|non-".$_;
16635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(added\s*|to\s*|from\s*|became\s*)($MKeys)([^\w-]|\Z)!$1<b>$2</b>$3!ig; # intrinsic types, modifiers
166370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
166380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # Markdown
166390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*\*([\w\-]+)\*\*!<b>$1</b>!ig;
166400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*([\w\-]+)\*!<i>$1</i>!ig;
16641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub applyMacroses($$$$)
16645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind, $Content, $Problem) = @_;
16647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Problem->{"Word_Size"} = $WORD_SIZE{2};
16649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content = addMarkup($Content);
16650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # macros
16651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Value = $Problem->{$Attr};
16655dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(not defined $Value
16656dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        or $Value eq "") {
16657dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            next;
16658dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
1665928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1666028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(index($Content, $Macro)==-1) {
1666128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            next;
1666228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1666328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1666428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Kind!~/\A(Changed|Added|Removed)_Constant\Z/
1666528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Kind!~/_Type_/
1666628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Value=~/\s\(/ and $Value!~/['"]/)
16667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # functions
166681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s*\[[\w\-]+\]//g; # remove quals
1666928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            $Value=~s/\s[a-z]\w*(\)|,)/$1/ig; # remove parameter names
16670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = black_name($Value);
16671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\s/) {
16673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<span class='value'>".htmlSpecChars($Value)."</span>";
16674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\A\d+\Z/
16676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and ($Attr eq "Old_Size" or $Attr eq "New_Size"))
16677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # bits to bytes
16678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Value % $BYTE_SIZE)
16679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bits
16680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bit";
16682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bits";
16685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bytes
16689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value /= $BYTE_SIZE;
16690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> byte";
16692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bytes";
16695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
166980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else
166990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
16700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<b>".htmlSpecChars($Value)."</b>";
16701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\Q$Macro\E/$Value/g;
16703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/(\A|[^\@\w])\@\w/)
16706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $IncompleteRules{$Level}{$Kind})
16708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only one warning
16709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "incomplete rule \"$Kind\" (\"$Level\")");
16710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $IncompleteRules{$Level}{$Kind} = 1;
16711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16716dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub get_Report_SymbolProblems($$)
16717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
167181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
167191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $INTERFACE_PROBLEMS = "";
167201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my (%ReportMap, %SymbolChanges) = ();
167212489ef88760861175102e4508089608391beead3Andrey Ponomarenko
167221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
167241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
167251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
167261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
167271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
167281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols"
167311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Kind ne "Added_Symbol" and $Kind ne "Removed_Symbol")
16732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
167331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
167341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
167351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $DyLib and my $VSym = $SymVer{1}{$Symbol})
16736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Symbol with Version
16737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DyLib = $Symbol_Library{1}{$VSym};
16738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1673962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $DyLib)
1674062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # const global data
1674162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $DyLib = "";
1674262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
167431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
167441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
167451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
167461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
167471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$SymbolChanges{$Symbol}{$Kind}} = %{$CompatProblems{$Level}{$Symbol}{$Kind}};
167481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
167502489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
167512489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity ne $TargetSeverity) {
167521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        delete($SymbolChanges{$Symbol}{$Kind}{$Location});
16753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not keys(%{$SymbolChanges{$Symbol}{$Kind}}))
167561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
167571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    delete($SymbolChanges{$Symbol}{$Kind});
167581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    next;
16759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$SymbolChanges{$Symbol}})) {
167641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolChanges{$Symbol});
167651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
167672489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
167701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
167731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    <library name=\"$DyLib\">\n";
16776d59580888a06555261f3d4255d9c2cfcb408a51aAndrey 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}});
16777d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
16778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      <symbol name=\"$Symbol\">\n";
167809e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                    foreach my $Kind (sort keys(%{$SymbolChanges{$Symbol}}))
16781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
167850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16786f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        <problem id=\"$Kind\">\n";
16788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16792d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16793d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                $INTERFACE_PROBLEMS .= "          <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16794d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            }
16795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        </problem>\n";
16796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      </symbol>\n";
16799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    </library>\n";
16801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  </header>\n";
16803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $INTERFACE_PROBLEMS = "<problems_with_symbols severity=\"$TargetSeverity\">\n".$INTERFACE_PROBLEMS."</problems_with_symbols>\n\n";
16805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
168091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my (%NameSpaceSymbols, %NewSignature) = ();
168141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1681574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
16816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
168171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
168191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= getTitle($HeaderName, $DyLib, $NameSpace);
1682028874769f026cec2a4c1ac1dfc975eda75275734Andrey 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}});
168211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
168231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
168241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $SYMBOL_REPORT = "";
16825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemNum = 1;
1682628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko                        foreach my $Kind (sort keys(%{$SymbolChanges{$Symbol}}))
16827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
168281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
168301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
168310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if($Problem{"New_Signature"}) {
168331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $NewSignature{$Symbol} = $Problem{"New_Signature"};
16834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                {
16837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
168389e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                    $SYMBOL_REPORT .= "<tr>\n<th>$ProblemNum</th>\n<td>".$Change."</td>\n<td>".$Effect."</td>\n</tr>\n";
16839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemNum += 1;
16840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemsNum += 1;
16841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemNum -= 1;
168451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($SYMBOL_REPORT)
16846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
168479e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            my $ShowSymbol = $Symbol;
16848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
168499e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $ShowSymbol = highLight_Signature_Italic_Color($Signature);
16850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
168519e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
168529e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            if($NameSpace)
168539e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            {
168549e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $SYMBOL_REPORT = cut_Namespace($SYMBOL_REPORT, $NameSpace);
168559e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $ShowSymbol = cut_Namespace($ShowSymbol, $NameSpace);
16856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
168579e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
168589e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanStart."<span class='ext'>[+]</span> ".$ShowSymbol." ($ProblemNum)".$ContentSpanEnd."<br/>\n";
168591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivStart."\n";
168609e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
168619e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            if(my $NSign = $NewSignature{$Symbol})
168621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # argument list changed to
168639e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                if($NameSpace) {
168649e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                    $NSign = cut_Namespace($NSign, $NameSpace);
168659e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                }
168669e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "\n<span class='new_sign_lbl'>changed to:</span>\n<br/>\n<span class='new_sign'>".highLight_Signature_Italic_Color($NSign)."</span><br/>\n";
16867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
168689e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
168691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Symbol=~/\A(_Z|\?)/) {
168701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "<span class='mangled'>&#160;&#160;&#160;&#160;[symbol: <b>$Symbol</b>]</span><br/>\n";
168711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
168729e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
1687315bfdc281d18ec26a6a056ed45d641a885716165Andrey 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";
168741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivEnd;
16875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1687715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "<br/>\n";
16878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168812489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($INTERFACE_PROBLEMS)
16883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $INTERFACE_PROBLEMS = insertIDs($INTERFACE_PROBLEMS);
168851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Symbols, $TargetSeverity Severity";
168861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Symbols";
16889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
168900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey 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";
16891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $INTERFACE_PROBLEMS;
16894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
168969e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenkosub cut_Namespace($$)
168979e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko{
168989e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    my ($N, $Ns) = @_;
168999e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    $N=~s/\b\Q$Ns\E:://g;
169009e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko    return $N;
169019e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko}
169029e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
16903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_TypeProblems($$)
16904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
169051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
169061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $TYPE_PROBLEMS = "";
1690774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my (%ReportMap, %TypeChanges) = ();
169082489ef88760861175102e4508089608391beead3Andrey Ponomarenko
169091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
169111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
16912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
16914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16915f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
16916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
169171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $TypeName = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
169181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
16919f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
169202489ef88760861175102e4508089608391beead3Andrey Ponomarenko
169211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Severity eq "Safe"
169221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $TargetSeverity ne "Safe") {
16923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
16924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
169251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
169262489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$TypeName}{$Kind}{$Target})
169272489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    {
169282489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
169292489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        { # select a problem with the highest priority
169302489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            next;
169312489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        }
16932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
169332489ef88760861175102e4508089608391beead3Andrey Ponomarenko
169342489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $TypeChanges{$TypeName}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
16935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
169392489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Kinds_Locations = ();
16941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $TypeName (keys(%TypeChanges))
16942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
169432489ef88760861175102e4508089608391beead3Andrey Ponomarenko        my %Kind_Target = ();
16944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (sort keys(%{$TypeChanges{$TypeName}}))
16945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16946f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16948f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
169491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Severity ne $TargetSeverity)
16950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # other priority
16951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Locations{$TypeName}{$Kind}{$Location} = 1;
16955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges{$TypeName}{$Kind}{$Location}{"Target"};
169562489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Kind_Target{$Kind}{$Target})
16957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicate target
16958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
169612489ef88760861175102e4508089608391beead3Andrey Ponomarenko                $Kind_Target{$Kind}{$Target} = 1;
1696262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $HeaderName = $TypeInfo{1}{$TName_Tid{1}{$TypeName}}{"Header"};
169631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$TypeName} = 1;
16964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not keys(%{$TypeChanges{$TypeName}{$Kind}})) {
16966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($TypeChanges{$TypeName}{$Kind});
16967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
169691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$TypeChanges{$TypeName}})) {
169701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($TypeChanges{$TypeName});
169711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
169732489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16974850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$CompatProblems{$Level}});
16975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
169771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
169801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}}))
16981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
169825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                $TYPE_PROBLEMS .= "    <type name=\"".xmlSpecChars($TypeName)."\">\n";
16983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      <problem id=\"$Kind\">\n";
16989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16993d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16994d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            $TYPE_PROBLEMS .= "        <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16995d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        }
16996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      </problem>\n";
16997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16999850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $TYPE_PROBLEMS .= getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
170001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
17001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TYPE_PROBLEMS .= showVTables($TypeName);
17002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TYPE_PROBLEMS .= "    </type>\n";
17004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  </header>\n";
17006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TYPE_PROBLEMS = "<problems_with_types severity=\"$TargetSeverity\">\n".$TYPE_PROBLEMS."</problems_with_types>\n\n";
17008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
17011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
170121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
17013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my (%NameSpace_Type) = ();
170151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}})) {
1701674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpace_Type{select_Type_NS($TypeName, 1)}{$TypeName} = 1;
17017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpace_Type))
17019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
170201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= getTitle($HeaderName, "", $NameSpace);
1702174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my @SortedTypes = sort {lc(show_Type($a, 0, 1)) cmp lc(show_Type($b, 0, 1))} keys(%{$NameSpace_Type{$NameSpace}});
17022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $TypeName (@SortedTypes)
17023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemNum = 1;
17025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $TYPE_REPORT = "";
170262489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
17028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17029f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
17030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
17031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
17032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
17033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
17034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
170359e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                                $TYPE_REPORT .= "<tr>\n<th>$ProblemNum</th>\n<td>".$Change."</td>\n<td>$Effect</td>\n</tr>\n";
17036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemNum += 1;
17037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemsNum += 1;
17038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
17039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemNum -= 1;
17042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TYPE_REPORT)
17043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17044850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Affected = getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
17045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ShowVTables = "";
170461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
17047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ShowVTables = showVTables($TypeName);
17048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1704974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
170509e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        my $ShowType = show_Type($TypeName, 1, 1);
170519e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
170529e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        if($NameSpace)
170539e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        {
170549e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $TYPE_REPORT = cut_Namespace($TYPE_REPORT, $NameSpace);
170559e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $ShowType = cut_Namespace($ShowType, $NameSpace);
170569e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $Affected = cut_Namespace($Affected, $NameSpace);
170579e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                            $ShowVTables = cut_Namespace($ShowVTables, $NameSpace);
170589e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        }
170599e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko
170609e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanStart."<span class='ext'>[+]</span> ".$ShowType." ($ProblemNum)".$ContentSpanEnd;
170611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<br/>\n".$ContentDivStart."<table class='ptable'><tr>\n";
170621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th width='2%'></th><th width='47%'>Change</th>\n";
170631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th>Effect</th></tr>".$TYPE_REPORT."</table>\n";
170641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ShowVTables.$Affected."<br/><br/>".$ContentDivEnd."\n";
17065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1706715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TYPE_PROBLEMS .= "<br/>\n";
17068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170702489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TYPE_PROBLEMS)
17072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = insertIDs($TYPE_PROBLEMS);
170741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Data Types, $TargetSeverity Severity";
170751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
17076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
17077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Data Types";
17078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
170791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = "<a name=\'".get_Anchor("Type", $Level, $TargetSeverity)."\'></a>\n<h2>$Title ($ProblemsNum)</h2><hr/>\n".$TYPE_PROBLEMS.$TOP_REF."<br/>\n";
17080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TYPE_PROBLEMS;
17083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1708574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub show_Type($$$)
1708674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
1708774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Name, $Html, $LibVersion) = @_;
1708874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TType = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$Name}}{"Type"};
1708974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $TType = lc($TType);
1709074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TType=~/struct|union|enum/) {
1709174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name=~s/\A\Q$TType\E //g;
1709274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1709374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($Html) {
1709474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = "<span class='ttype'>".$TType."</span> ".htmlSpecChars($Name);
1709574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1709674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else {
1709774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = $TType." ".$Name;
1709874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1709974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Name;
1710074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
1710174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
171021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Anchor($$$)
171031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
171041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Kind, $Level, $Severity) = @_;
171051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
171061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
171071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
171081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_".$Level."_Changes_In_".$Kind."s";
171091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
171111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_".$Level."_Problems_".$Severity;
171121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
171141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
171151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
171161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
171171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_Changes_In_".$Kind."s";
171181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
171201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_Problems_".$Severity;
171211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
171231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
171241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
17125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showVTables($)
17126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
17128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId1 = $TName_Tid{1}{$TypeName};
1712962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($TypeId1, 1);
17130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Type1{"VTable"}
17131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$Type1{"VTable"}}))
17132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeId2 = $TName_Tid{2}{$TypeName};
1713462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type2 = get_Type($TypeId2, 2);
17135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Type2{"VTable"}
17136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and keys(%{$Type2{"VTable"}}))
17137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Indexes = map {$_=>1} (keys(%{$Type1{"VTable"}}), keys(%{$Type2{"VTable"}}));
17139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Entries = ();
171401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Index (sort {int($a)<=>int($b)} (keys(%Indexes)))
17141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
171421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E1"} = simpleVEntry($Type1{"VTable"}{$Index});
171431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E2"} = simpleVEntry($Type2{"VTable"}{$Index});
17144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $VTABLES = "";
17146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ReportFormat eq "xml")
17147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # XML
17148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      <vtable>\n";
171491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
171511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "        <entry offset=\"".$Index."\">\n";
171525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <old>".xmlSpecChars($Entries{$Index}{"E1"})."</old>\n";
171535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <new>".xmlSpecChars($Entries{$Index}{"E2"})."</new>\n";
17154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $VTABLES .= "        </entry>\n";
17155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      </vtable>\n\n";
17157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # HTML
171601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES .= "<table class='vtable'>";
17161ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<tr><th>Offset</th>";
17162ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (Old) - ".(keys(%{$Type1{"VTable"}}))." entries</th>";
17163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (New) - ".(keys(%{$Type2{"VTable"}}))." entries</th></tr>";
171641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Color1, $Color2) = ("", "");
171678a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
171688a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    my $E1 = $Entries{$Index}{"E1"};
171698a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    my $E2 = $Entries{$Index}{"E2"};
171708a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
171718a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    if($E1 ne $E2
171728a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    and $E1!~/ 0x/
171738a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                    and $E2!~/ 0x/)
17174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
171751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Entries{$Index}{"E1"})
17176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
171771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color1 = " class='failed'";
171781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='failed'";
17179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
171811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='warning'";
17182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
171841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<tr><th>".$Index."</th>\n";
171851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color1>".htmlSpecChars($Entries{$Index}{"E1"})."</td>\n";
171861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color2>".htmlSpecChars($Entries{$Index}{"E2"})."</td></tr>\n";
17187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "</table><br/>\n";
17189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES = $ContentDivStart.$VTABLES.$ContentDivEnd;
171901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES = $ContentSpanStart_Info."[+] show v-table (old and new)".$ContentSpanEnd."<br/>\n".$VTABLES;
17191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VTABLES;
17193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
17196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simpleVEntry($)
17199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VEntry = $_[0];
17201dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not defined $VEntry
17202dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    or $VEntry eq "") {
17203dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return "";
17204dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
17205ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
17206ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    $VEntry=~s/ \[.+?\]\Z//; # support for ABI Dumper
17207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A(.+)::(_ZThn.+)\Z/$2/; # thunks
17208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/_ZTI\w+/typeinfo/g; # typeinfo
17209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($VEntry=~/\A_ZThn.+\Z/) {
17210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $VEntry = "non-virtual thunk";
17211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $VEntry=~s/\A\(int \(\*\)\(...\)\)\s*([a-z_])/$1/i;
17213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # support for old GCC versions
17214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A0u\Z/(int (*)(...))0/;
17215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A4294967268u\Z/(int (*)(...))-0x000000004/;
17216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A&_Z\Z/& _Z/;
17217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/([^:]+)::\~([^:]+)\Z/~$1/; # destructors
17218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VEntry;
17219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17221f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub adjustParamPos($$$)
17222f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17223f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $Symbol, $LibVersion) = @_;
17224f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol})
17225f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17226f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$Symbol}{"Static"}
17227f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        and $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
17228f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17229f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return $Pos-1;
17230f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17231f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17232f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Pos;
17233f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17234f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17235f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17236f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17237f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17238f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamPos($$$)
17239f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17240f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
17241f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17242f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
17243f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"})
17244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17245f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17246f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach (keys(%{$Info->{"Param"}}))
17247f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17248f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info->{"Param"}{$_}{"name"} eq $Name)
17249f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17250f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return $_;
17251f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17252f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17253f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17254f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17255f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17256f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17257f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17258f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamName($)
17259f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17260f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Loc = $_[0];
17261f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Loc=~s/\->.*//g;
17262f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $Loc;
17263f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17264f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17265850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub getAffectedSymbols($$$$)
17266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Level, $Target_TypeName, $Kinds_Locations, $Syms) = @_;
17268ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
1726952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $LIMIT = 10;
17270ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    if(defined $AffectLimit) {
17271ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        $LIMIT = $AffectLimit;
17272ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    }
17273f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17274ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my @Kinds = sort keys(%{$Kinds_Locations});
17275ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my %KLocs = ();
17276ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    foreach my $Kind (@Kinds)
17277f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
172789e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        my @Locs = sort {$a=~/retval/ cmp $b=~/retval/} sort {length($a)<=>length($b)} sort keys(%{$Kinds_Locations->{$Kind}});
17279ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        $KLocs{$Kind} = \@Locs;
17280f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
1728152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1728252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %SymLocKind = ();
1728352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    foreach my $Symbol (@{$Syms})
17284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
172852489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(index($Symbol, "_Z")==0
172862489ef88760861175102e4508089608391beead3Andrey Ponomarenko        and $Symbol=~/(C2|D2|D0)[EI]/)
17287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # duplicated problems for C2 constructors, D2 and D0 destructors
17288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
172902489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17291ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        foreach my $Kind (@Kinds)
17292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
172932489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if(not defined $CompatProblems{$Level}{$Symbol}
172942489ef88760861175102e4508089608391beead3Andrey Ponomarenko            or not defined $CompatProblems{$Level}{$Symbol}{$Kind}) {
172952489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next;
172962489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
172972489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17298ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            foreach my $Loc (@{$KLocs{$Kind}})
17299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1730052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if(not defined $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}) {
17301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
173032489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17304ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                if(index($Symbol, "\@")!=-1
17305ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                or index($Symbol, "\$")!=-1)
17306ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                {
17307ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    my ($SN, $SS, $SV) = separate_symbol($Symbol);
17308ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17309ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    if($Level eq "Source")
17310ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    { # remove symbol version
17311ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                        $Symbol = $SN;
17312ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    }
17313ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17314ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    if($SV and defined $CompatProblems{$Level}{$SN}
17315ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    and defined $CompatProblems{$Level}{$SN}{$Kind}{$Loc})
17316ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    { # duplicated problems for versioned symbols
17317ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                        next;
17318ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                    }
17319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
173202489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1732152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                my $Type_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}{"Type_Name"};
173222489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Type_Name ne $Target_TypeName) {
173232489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    next;
173242489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
17325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1732652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymLocKind{$Symbol}{$Loc}{$Kind} = 1;
17327ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko                last;
17328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17330ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17331ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        # if(keys(%SymLocKind)>=$LIMIT)
17332ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        # {
17333ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        #     last;
17334ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        # }
17335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1733652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17337ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    %KLocs = (); # clear
17338ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17339ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my %SymSel = ();
17340ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    my $Num = 0;
17341ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko    foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymLocKind))
1734252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1734352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        LOOP: foreach my $Loc (sort {$a=~/retval/ cmp $b=~/retval/} sort {length($a)<=>length($b)} sort keys(%{$SymLocKind{$Symbol}}))
1734452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
17345ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            foreach my $Kind (sort keys(%{$SymLocKind{$Symbol}{$Loc}}))
1734652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
1734752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Loc"} = $Loc;
1734852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Kind"} = $Kind;
1734952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last LOOP;
1735052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1735152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
17352ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17353ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        $Num += 1;
17354ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko
17355ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        if($Num>=$LIMIT) {
17356ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            last;
17357ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        }
17358850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
1735952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Affected = "";
1736152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
17364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      <affected>\n";
1736552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1736652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17368ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Loc = $SymSel{$Symbol}{"Loc"};
1736952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $PName = getParamName($Loc);
17370ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $SymSel{$Symbol}{"Kind"}, $Loc);
1737152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Target = "";
1737352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($PName)
17374d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            {
1737552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Target .= " param=\"$PName\"";
1737652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Desc=~s/parameter $PName /parameter \@param /;
17377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1737852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Aretval(\-|\Z)/i) {
17379d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"retval\"";
17380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1738152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Athis(\-|\Z)/i) {
17382d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"this\"";
17383d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            }
17384d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1738552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Desc=~s/\AField ([^\s]+) /Field \@field /) {
17386d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " field=\"$1\"";
17387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17388d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17389d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            $Affected .= "        <symbol name=\"$Symbol\"$Target>\n";
1739052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "          <comment>".xmlSpecChars($Desc)."</comment>\n";
17391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "        </symbol>\n";
17392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      </affected>\n";
17394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
1739752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1739952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $SymSel{$Symbol}{"Kind"}, $SymSel{$Symbol}{"Loc"});
1740052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $S = get_Signature($Symbol, 1);
1740101e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko            my $PName = getParamName($SymSel{$Symbol}{"Loc"});
1740252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Pos = adjustParamPos(getParamPos($PName, $Symbol, 1), $Symbol, 1);
1740352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1740415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            $Affected .= "<span class='iname_a'>".highLight_Signature_PPos_Italic($S, $Pos, 1, 0, 0)."</span><br/>\n";
1740552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "<div class='affect'>".htmlSpecChars($Desc)."</div>\n";
17406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1740752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17408ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko        if(keys(%SymLocKind)>$LIMIT) {
17409ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            $Affected .= " <b>...</b>\n<br/>\n"; # and others ...
17410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1741152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1741215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        $Affected = "<div class='affected'>".$Affected."</div>\n";
17413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Affected)
17414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected = $ContentDivStart.$Affected.$ContentDivEnd;
17416ba8922775121372b6e35f925f3938282ef03019eAndrey Ponomarenko            $Affected = $ContentSpanStart_Affected."[+] affected symbols (".keys(%SymLocKind).")".$ContentSpanEnd.$Affected;
17417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
174192489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Affected;
17421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17423f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub cmpLocations($$)
17424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1742562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($L1, $L2) = @_;
17426f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($L2=~/\A(retval|this)\b/
17427f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and $L1!~/\A(retval|this)\b/)
17428f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17429f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($L1!~/\-\>/) {
17430f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17431f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17432f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($L2=~/\-\>/) {
17433f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17434f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
17437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17439f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getAffectDesc($$$$)
17440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
174411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Symbol, $Kind, $Location) = @_;
17442f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
174431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my %Problem = %{$CompatProblems{$Level}{$Symbol}{$Kind}{$Location}};
17444f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17445f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Location_I = $Location;
17446f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Location=~s/\A(.*)\-\>(.+?)\Z/$1/; # without the latest affected field
17447f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Sentence = ();
17449f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Kind eq "Overridden_Virtual_Method"
17451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Kind eq "Overridden_Virtual_Method_B") {
17452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Sentence, "The method '".$Problem{"New_Value"}."' will be called instead of this method.");
17453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
17455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17456f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %SymInfo = %{$CompleteSignature{1}{$Symbol}};
17457f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Location eq "this" or $Kind=~/(\A|_)Virtual(_|\Z)/)
17459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17460f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $METHOD_TYPE = $SymInfo{"Constructor"}?"constructor":"method";
17461f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $ClassName = $TypeInfo{1}{$SymInfo{"Class"}}{"Name"};
17462f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ClassName eq $Problem{"Type_Name"}) {
17464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from \'".$Problem{"Type_Name"}."\' class.");
17465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from derived class \'".$ClassName."\'.");
17468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
17471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17472f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $TypeID = undef;
17473f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location=~/retval/)
17475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # return value
17476f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in return value");
17478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Return value");
17481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17482f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17483f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Return"};
17484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/this/)
17486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "this" pointer
17487f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in the object of this method");
17489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'this\' pointer");
17492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17493f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17494f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Class"};
17495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # parameters
17498f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17499f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PName = getParamName($Location);
17500f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PPos = getParamPos($PName, $Symbol, 1);
17501f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17502f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17503f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in ".showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17506f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17508f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($PName) {
17509f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "\'".$PName."\'");
17510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17511f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17512f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Param"}{$PPos}{"type"};
17513f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17514f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17515f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Location!~/this/)
17516f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17517f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(my %PureType = get_PureType($TypeID, $TypeInfo{1}))
17518dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17519f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($PureType{"Type"} eq "Pointer") {
17520dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17521dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17522f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    elsif($PureType{"Type"} eq "Ref") {
17523dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17524dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17527f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location eq "this") {
17529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17531f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            else
17532f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17533f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Location_T = $Location;
17534f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $Location_T=~s/\A\w+(\->|\Z)//; # location in type
17535f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17536f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $TypeID_Problem = $TypeID;
17537f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($Location_T) {
17538f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeID_Problem = getFieldType($Location_T, $TypeID, 1);
17539f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17540f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17541f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($TypeInfo{1}{$TypeID_Problem}{"Name"} eq $Problem{"Type_Name"}) {
17542f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has type \'".$Problem{"Type_Name"}."\'.");
17543f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17544f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                else {
17545f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17546f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1755062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($ExtendedSymbols{$Symbol}) {
175518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        push(@Sentence, " This is a symbol from an external library that may use the \'$TargetLibraryName\' library and change the ABI after recompiling.");
17552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17553d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17554d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my $Sent = join(" ", @Sentence);
17555d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1755652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Sent=~s/->/./g;
1755752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17558d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($ReportFormat eq "xml")
17559d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
17560d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Sent=~s/'//g;
17561d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
17562d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17563d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    return $Sent;
17564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17566f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getFieldType($$$)
17567f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17568f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Location, $TypeId, $LibVersion) = @_;
17569f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17570d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Fields = split(/\->/, $Location);
17571f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17572f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $Name (@Fields)
17573f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17574f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %Info = get_BaseType($TypeId, $LibVersion);
17575f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17576f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Pos (keys(%{$Info{"Memb"}}))
17577f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17578f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info{"Memb"}{$Pos}{"name"} eq $Name)
17579f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17580f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeId = $Info{"Memb"}{$Pos}{"type"};
17581f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                last;
17582f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17583f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17584f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17585f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17586f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $TypeId;
17587f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17588f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_XmlSign($$)
17590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
17592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "";
17594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Info->{"Param"}}))
17595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Name = $Info->{"Param"}{$Pos}{"name"};
1759762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Type = $Info->{"Param"}{$Pos}{"type"};
1759862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TypeName = $TypeInfo{$LibVersion}{$Type}{"Name"};
17599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
17600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
176028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeName=~s/\b\Q$Typedef\E\b/$Base/g;
176038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
17604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <param pos=\"$Pos\">\n";
17606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "      <name>".$Name."</name>\n";
176075c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($TypeName)."</type>\n";
17608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </param>\n";
17609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Return = $Info->{"Return"})
17611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1761262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $RTName = $TypeInfo{$LibVersion}{$Return}{"Name"};
17613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <retval>\n";
176145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($RTName)."</type>\n";
17615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </retval>\n";
17616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_SymbolsInfo($)
17621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "<symbols_info>\n";
176241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
17625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
176261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
176271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
17628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  <symbol name=\"$Symbol\">\n";
17631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($S1, $P1, $S2, $P2) = ();
176321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $AddedInt{$Level}{$Symbol})
17633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{1}{$Symbol}
17635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{1}{$Symbol}{"Header"})
17636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P1 = get_XmlSign($Symbol, 1);
17638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = get_Signature($Symbol, 1);
17639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = $tr_name{$Symbol};
17642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
176441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $RemovedInt{$Level}{$Symbol})
17645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$Symbol}
17647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{2}{$Symbol}{"Header"})
17648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P2 = get_XmlSign($Symbol, 2);
17650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = get_Signature($Symbol, 2);
17651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = $tr_name{$Symbol};
17654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S1)
17657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <old signature=\"".xmlSpecChars($S1)."\">\n";
17659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P1;
17660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </old>\n";
17661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S2 and $S2 ne $S1)
17663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176645c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <new signature=\"".xmlSpecChars($S2)."\">\n";
17665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P2;
17666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </new>\n";
17667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  </symbol>\n";
17669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report .= "</symbols_info>\n";
17671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub writeReport($$)
17675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Report) = @_;
176771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($ReportFormat eq "xml") {
176781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".$Report;
176791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
176811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --stdout option
176821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        print STDOUT $Report;
176831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
176851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
176861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $RPath = getReportPath($Level);
17687850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        mkpath(get_dirname($RPath));
17688850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
17689850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(REPORT, ">", $RPath) || die ("can't open file \'$RPath\': $!\n");
17690850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        print REPORT $Report;
17691850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(REPORT);
1769262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1769362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1769462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
176951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReport($)
176961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
176971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
177001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
177011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<reports>\n";
177031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Binary");
177041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Source");
177051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</reports>\n";
177061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
177081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
177091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<report kind=\"".lc($Level)."\" version=\"$XML_REPORT_VERSION\">\n\n";
177111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
177121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= $Summary."\n";
177131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
177141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
17715d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17716d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # additional symbols info (if needed)
17717d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # $Report .= get_Report_SymbolsInfo($Level);
17718d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
177191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</report>\n";
177201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
177251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $CssStyles = readModule("Styles", "Report.css");
177261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $JScripts = readModule("Scripts", "Sections.js");
177271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
177281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CssStyles .= "\n".readModule("Styles", "Tabs.css");
177301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JScripts .= "\n".readModule("Scripts", "Tabs.js");
1773114b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." compatibility report";
1773241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Keywords = $TargetTitle.", compatibility, API, ABI, report";
1773341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Description = "API/ABI compatibility report for the $TargetTitle $TargetComponent between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
177341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($BSummary, $BMetaData) = get_Summary("Binary");
177351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SSummary, $SMetaData) = get_Summary("Source");
177361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
1773752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title("Join")."
1773815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            <br/>
1773915bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            <div class='tabset'>
177401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
177411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
177421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            </div>";
177431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
177441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
1774541834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1774652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
177471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
177491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
177501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
1775214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." ".lc($Level)." compatibility report";
1775314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Keywords = $TargetTitle.", ".lc($Level)." compatibility, API, report";
1775414b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Description = "$Level compatibility report for the ".$TargetTitle." ".$TargetComponent." between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
177551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
177561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
177571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(getArch(1) eq getArch(2)
177581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and getArch(1) ne "unknown") {
177591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Description .= " on ".showArch(getArch(1));
177601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
177611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
177621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $MetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."\n<body>\n<div><a name='Top'></a>\n";
1776352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title($Level)."\n".$Summary."\n";
177641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
177651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
177661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_SourceInfo();
1776741834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= "</div>\n<br/><br/><br/>\n";
1776841834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1776952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
177701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
177731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
177741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
177751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getLegend()
177761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
177771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "<br/>
177781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<table class='summary'>
177791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
177801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='new'>added</td>
177811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='passed'>compatible</td>
177821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr>
177831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
177841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='warning'>warning</td>
177851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='failed'>incompatible</td>
177861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr></table>\n";
177871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
177881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
177891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub createReport()
177901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
177911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
177920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # --stdout
177931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Join", getReport("Join"));
17794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
177951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($DoubleReport)
177961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
177971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
177981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
177991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
178001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
178011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
178021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
178031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
178041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
178051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
178061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
17807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1781041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenkosub getReportFooter()
17811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1781241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    my $Footer = "";
1781301e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko
178148a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "<hr/>\n";
178158a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "<div class='footer' align='right'>";
178168a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "<i>Generated by <a href='".$HomePage."'>ABI Compliance Checker</a> $TOOL_VERSION &#160;</i>\n";
178178a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko    $Footer .= "</div>\n";
1781841834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<br/>\n";
1781941834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko
17820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Footer;
17821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Problems($$)
17824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
178252489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my ($Severity, $Level) = @_;
1782652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
178272489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my $Report = get_Report_TypeProblems($Severity, $Level);
178282489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if(my $SProblems = get_Report_SymbolProblems($Severity, $Level)) {
178291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Report .= $SProblems;
17830dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1783152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1783252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($Severity eq "Low" or $Severity eq "Safe") {
1783352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Report .= get_Report_ChangedConstants($Severity, $Level);
178348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1783552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "html")
17837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Report)
17839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add anchor
178401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport)
178411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
178422489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
178431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_".$Level."_Changes\'></a>".$Report;
178441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
178451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
178462489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_".$Level."_Problems\'></a>".$Report;
178471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
178491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
178501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
178512489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
178521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_Changes\'></a>".$Report;
178531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
178541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
178552489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_Problems\'></a>".$Report;
178561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
178631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub composeHTML_Head($$$$$)
17864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
178651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Title, $Keywords, $Description, $Styles, $Scripts) = @_;
178663ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko
178673ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    my $Head = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
178683ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n";
178693ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<head>\n";
178703ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\n";
178713ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<meta name=\"keywords\" content=\"$Keywords\" />\n";
178723ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<meta name=\"description\" content=\"$Description\" />\n";
178733ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<title>$Title</title>\n";
178743ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<style type=\"text/css\">\n$Styles</style>\n";
178753ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\n$Scripts\n-->\n</script>\n";
178763ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    $Head .= "</head>\n";
178773ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko
178783ad495d27a8b114627d03abbe369b5b68d10fa62Andrey Ponomarenko    return $Head;
17879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub insertIDs($)
17882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Text = $_[0];
17884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Text=~/CONTENT_ID/)
17885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($Content_Counter)%2) {
17887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ContentID -= 1;
17888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Text=~s/CONTENT_ID/c_$ContentID/;
17890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ContentID += 1;
17891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content_Counter += 1;
17892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Text;
17894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkPreprocessedUnit($)
17897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
17899a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my ($CurHeader, $CurHeaderName) = ("", "");
1790074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $CurClass = ""; # extra info
179011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    open(PREPROC, $Path) || die ("can't open file \'$Path\': $!\n");
1790274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17903a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    while(my $Line = <PREPROC>)
179041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting public and private constants
17905a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(substr($Line, 0, 1) eq "#")
17906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17907a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            chomp($Line);
17908a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if($Line=~/\A\#\s+\d+\s+\"(.+)\"/)
17909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17910a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeader = path_format($1, $OSgroup);
17911a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeaderName = get_filename($CurHeader);
1791274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CurClass = "";
1791374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1791474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(index($CurHeader, $TMP_DIR)==0) {
1791574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    next;
1791674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1791774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(substr($CurHeaderName, 0, 1) eq "<")
17919fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # <built-in>, <command-line>, etc.
17920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeaderName = "";
17921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeader = "";
17922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1792474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($ExtraInfo)
1792574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
17926fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
1792774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $PreprocessedHeaders{$Version}{$CurHeader} = 1;
1792874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
1792974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
17930a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
1793174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not $ExtraDump)
179324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            {
17933fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($CurHeaderName)
17934fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17935fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $Include_Neighbors{$Version}{$CurHeaderName}
17936fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $Registered_Headers{$Version}{$CurHeader})
17937fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # not a target
17938fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17939fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17940fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not is_target_header($CurHeaderName, 1)
17941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not is_target_header($CurHeaderName, 2))
17942fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # user-defined header
17943fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17944fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
179454b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                }
17946a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
179474b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
179489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Line=~/\A\#\s*define\s+(\w+)\s+(.+)\s*\Z/)
17949a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
17950a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
17951a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if(not $Constants{$Version}{$Name}{"Access"})
17952a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
17953a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Access"} = "public";
17954a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Value"} = $Value;
17955fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
17956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Constants{$Version}{$Name}{"Header"} = $CurHeaderName;
17957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17958a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
17959a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
17960a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            elsif($Line=~/\A\#[ \t]*undef[ \t]+([_A-Z]+)[ \t]*/) {
17961a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Constants{$Version}{$1}{"Access"} = "private";
17962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1796474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
1796574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1796674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $ExtraDump)
1796774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1796874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/(\w+)\s*\(/)
1796974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # functions
1797074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1797174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1797274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #elsif($Line=~/(\w+)\s*;/)
1797374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #{ # data
1797474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1797574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #}
1797674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                elsif($Line=~/(\A|\s)class\s+(\w+)/) {
1797774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CurClass = $2;
1797874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1797974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1798074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
17983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
17984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1798574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Constants{$Version}{$Constant}{"Access"} eq "private")
1798674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1798774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
1798874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            next;
1798974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ExtraDump and ($Constant=~/_h\Z/i
17991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or isBuiltIn($Constants{$Version}{$Constant}{"Header"})))
1799274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # skip
1799374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
17994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
17996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($Constants{$Version}{$Constant}{"Access"});
17997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17999a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug)
18000a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
18001a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
18002a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        copy($Path, $DEBUG_PATH{$Version}."/preprocessor.txt");
18003a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
18004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
180061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub uncoverConstant($$)
180071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
180081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($LibVersion, $Constant) = @_;
180091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "" if(not $LibVersion or not $Constant);
180101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Constant if(isCyclical(\@RecurConstant, $Constant));
180111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"uncoverConstant"}{$LibVersion}{$Constant}) {
180121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"uncoverConstant"}{$LibVersion}{$Constant};
180131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18014fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18015fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Constants{$LibVersion}{$Constant})
180161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
18017fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value = $Constants{$LibVersion}{$Constant}{"Value"};
18018fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$LibVersion}{$Value})
180191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
180201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            push(@RecurConstant, $Constant);
180211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $Uncovered = uncoverConstant($LibVersion, $Value);
180221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Uncovered ne "") {
180231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Value = $Uncovered;
180241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
180251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            pop(@RecurConstant);
180261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
180281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # FIXME: uncover $Value using all the enum constants
18029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # USE CASE: change of define NC_LONG from NC_INT (enum value) to NC_INT (define)
180301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = $Value);
180311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
180321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = "");
180331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
180341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
18035fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub simpleConstant($$)
18036fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
18037fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Value) = @_;
18038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\W/)
18039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
18040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value_Copy = $Value;
18041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        while($Value_Copy=~s/([a-z_]\w+)/\@/i)
18042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Word = $1;
18044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($Value!~/$Word\s*\(/)
18045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Val = uncoverConstant($LibVersion, $Word);
18047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Val ne "")
18048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Value=~s/\b$Word\b/$Val/g;
18050fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18052fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
18055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
18056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18057fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub computeValue($)
18058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
18059fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $Value = $_[0];
18060fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18061fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A\((-?[\d]+)\)\Z/) {
18062fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return $1;
18063fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18064fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18065fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A[\d\-\+()]+\Z/) {
18066fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return eval($Value);
18067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18068fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18069fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
18070fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
18071fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
180729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %IgnoreConstant = map {$_=>1} (
180739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSION",
180749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSIONCODE",
180759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERNUM",
180769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERS_INFO",
180779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCHLEVEL",
180789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLPREFIX",
180799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VBUILD",
180809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VPATCH",
180819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VMINOR",
180829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_STRING",
180839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_TIME",
180849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_STRING",
180859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PRODUCTION",
180869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIGURE_COMMAND",
180879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLDIR",
180889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINDIR",
180899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIG_FILE_PATH",
180909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DATADIR",
180919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "EXTENSION_DIR",
180929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INCLUDE_PATH",
180939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LIBDIR",
180949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LOCALSTATEDIR",
180959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SBINDIR",
180969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SYSCONFDIR",
180979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "RELEASE",
180989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SOURCE_ID",
180999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SUBMINOR",
181009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINOR",
181019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINNOR",
181029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINORVERSION",
181039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJOR",
181049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJORVERSION",
181059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICRO",
181069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICROVERSION",
181079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINARY_AGE",
181089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INTERFACE_AGE",
181099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CORE_ABI",
181109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCH",
181119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COPYRIGHT",
181129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "TIMESTAMP",
181139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "REVISION",
181149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_TAG",
181159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGEDATE",
181169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NUMVERSION",
181179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Release",
181189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Version"
18119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
18120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
181218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub constantFilter($$$)
181228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
181238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Name, $Value, $Level) = @_;
181248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Level eq "Binary")
181268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
18127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Name=~/_t\Z/)
18128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # __malloc_ptr_t
18129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
18130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
181318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach (keys(%IgnoreConstant))
181328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
181338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Name=~/(\A|_)$_(_|\Z)/)
181348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # version
181358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
181368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(/\A[A-Z].*[a-z]\Z/)
181388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
181398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Name=~/(\A|[a-z])$_([A-Z]|\Z)/)
181408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # version
181418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return 1;
181428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
181438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
181458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Name=~/(\A|_)(lib|open|)$TargetLibraryShortName(_|)(VERSION|VER|DATE|API|PREFIX)(_|\Z)/i)
181468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # version
181478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
181498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Value=~/\A('|"|)[\/\\]\w+([\/\\]|:|('|"|)\Z)/ or $Value=~/[\/\\]\w+[\/\\]\w+/)
181508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # /lib64:/usr/lib64:/lib:/usr/lib:/usr/X11R6/lib/Xaw3d ...
181518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18153fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A["'].*['"]/i)
18155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # string
18156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
18157fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18158fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[({]*\s*[a-z_]+\w*(\s+|[\|,])/i)
18160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # static int gcry_pth_init
18161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # extern ABC
181628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # (RE_BACKSLASH_ESCAPE_IN_LISTS | RE...
18163fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # { H5FD_MEM_SUPER, H5FD_MEM_SUPER, ...
181648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\w+\s*\(/i)
181678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # foo(p)
181688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[a-z_]+\w*\Z/i)
181718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # asn1_node_st
18172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # __SMTH_P
181738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
181758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
181768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
181788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
181798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeConstants($)
18181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
181821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
18183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{1}}))
18184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipConstants{1}{$Constant})
18186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skipped by the user
18187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
181898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Header = $Constants{1}{$Constant}{"Header"})
18191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not is_target_header($Header, 1)
18193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and not is_target_header($Header, 2))
18194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # user-defined header
18195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18198fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        else {
18199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
182018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value = uncoverConstant(1, $Constant);
182038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(constantFilter($Constant, $Old_Value, $Level))
182058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # separate binary and source problems
182068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{2}{$Constant}{"Value"})
182108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # removed
182118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Removed_Constant"}} = (
182128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
182138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Old_Value"=>$Old_Value  );
182148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Constants{2}{$Constant}{"Value"} eq "")
182188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # empty value
182198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # TODO: implement a rule
182208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value = uncoverConstant(2, $Constant);
182248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value_Pure = $Old_Value;
182268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value_Pure = $New_Value;
182278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/(\W)\s+/$1/g;
18229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/\s+(\W)/$1/g;
18230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/(\W)\s+/$1/g;
18231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/\s+(\W)/$1/g;
182328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($New_Value_Pure eq "" or $Old_Value_Pure eq "");
18234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($New_Value_Pure ne $Old_Value_Pure)
18236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different values
18237fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(simpleConstant(1, $Old_Value) eq simpleConstant(2, $New_Value))
18238fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # complex values
18239fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18240fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18241fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(computeValue($Old_Value) eq computeValue($New_Value))
18242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # expressions
18243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(convert_integer($Old_Value) eq convert_integer($New_Value))
18246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0x0001 and 0x1, 0x1 and 1 equal constants
18247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "0" and $New_Value eq "NULL")
18250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0 => NULL
18251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "NULL" and $New_Value eq "0")
18254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # NULL => 0
18255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
182578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Changed_Constant"}} = (
18258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Constant,
18259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Value"=>$Old_Value,
18260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Value"=>$New_Value  );
18261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
182638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$Constants{2}}))
182658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
182668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{1}{$Constant}{"Value"})
182678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
182688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SkipConstants{2}{$Constant})
182698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # skipped by the user
182708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
182718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
182728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $Header = $Constants{2}{$Constant}{"Header"})
18274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(not is_target_header($Header, 1)
18276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not is_target_header($Header, 2))
18277fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # user-defined header
18278fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    next;
18279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
182828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
182838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
182848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $New_Value = uncoverConstant(2, $Constant);
182868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $New_Value or $New_Value eq "") {
182878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
182888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
182898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(constantFilter($Constant, $New_Value, $Level))
182918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # separate binary and source problems
182928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
182938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
182948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Added_Constant"}} = (
182968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
182978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "New_Value"=>$New_Value  );
182988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
18300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub convert_integer($)
18303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Value = $_[0];
18305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Value=~/\A0x[a-f0-9]+\Z/)
183061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # hexadecimal
18307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return hex($Value);
18308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0[0-7]+\Z/)
183101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # octal
18311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0b[0-1]+\Z/)
183141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # binary
18315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
18318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Value;
18319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
183221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols($)
18323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1832562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @LibPaths = getSOPaths($LibVersion);
183261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($#LibPaths==-1 and not $CheckHeadersOnly)
18327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibVersion==1)
18329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
18331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
18332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries are not found in ".$Descriptor{$LibVersion}{"Version"});
18335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18337570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
183384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $LibPath (@LibPaths) {
183399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        readSymbols_Lib($LibVersion, $LibPath, 0, "+Weak", 1, 1);
18340570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18341570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18342570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($CheckUndefined)
18343570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18344570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my %UndefinedLibs = ();
18345570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1834674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Libs = (keys(%{$Library_Symbol{$LibVersion}}), keys(%{$DepLibrary_Symbol{$LibVersion}}));
1834774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1834874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $LibName (sort @Libs)
18349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
1835074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $UndefinedSymbols{$LibVersion}{$LibName})
18351570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
1835274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                foreach my $Symbol (keys(%{$UndefinedSymbols{$LibVersion}{$LibName}}))
18353570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18354fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Symbol_Library{$LibVersion}{$Symbol}
18355fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $DepSymbol_Library{$LibVersion}{$Symbol})
18356fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported by target library
18357fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18358fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18359fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(index($Symbol, '@')!=-1)
18360fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported default symbol version (@@)
18361fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Symbol=~s/\@/\@\@/;
18362fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Symbol_Library{$LibVersion}{$Symbol}
18363fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or $DepSymbol_Library{$LibVersion}{$Symbol}) {
18364fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            next;
1836574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        }
18366570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18367fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $Path (find_SymbolLibs($LibVersion, $Symbol)) {
18368fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $UndefinedLibs{$Path} = 1;
18369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18372570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($ExtraInfo)
18374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # extra information for other tools
18375fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my @Paths = sort keys(%UndefinedLibs))
18376570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18377570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $LibString = "";
18378fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my %Dirs = ();
18379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach (@Paths)
18380570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
1838174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $KnownLibs{$_} = 1;
18382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    my ($Dir, $Name) = separate_path($_);
18383570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18384570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Dir eq $_} (@{$SystemPaths{"lib"}})) {
18385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Dirs{esc($Dir)} = 1;
18386570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18387570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18388570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name = parse_libname($Name, "name", $OStarget);
18389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name=~s/\Alib//;
18390570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1839174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $LibString .= " -l$Name";
18392570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Dir (sort {$b cmp $a} keys(%Dirs))
18395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $LibString = " -L".esc($Dir).$LibString;
18397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18399570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                writeFile($ExtraInfo."/libs-string", $LibString);
18400570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18401570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
184021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18403570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1840474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo) {
1840574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/lib-paths", join("\n", sort keys(%KnownLibs)));
1840674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1840774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
184081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $CheckHeadersOnly)
184091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
184101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($#LibPaths!=-1)
184111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
184121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$Symbol_Library{$LibVersion}}))
184131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
184140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                printMsg("WARNING", "the set of public symbols in library(ies) is empty ($LibVersion)");
184151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                printMsg("WARNING", "checking headers only");
184161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $CheckHeadersOnly = 1;
184171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
184181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18420850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1842107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko   # clean memory
18422850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko   %SystemObjects = ();
18423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18425570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Prefix_Lib_Map=(
18426570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by prefix)
18427570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pthread_" => ["libpthread"],
18428570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "g_" => ["libglib-2.0", "libgobject-2.0", "libgio-2.0"],
18429570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cairo_" => ["libcairo"],
18430570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gtk_" => ["libgtk-x11-2.0"],
18431570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "atk_" => ["libatk-1.0"],
18432570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gdk_" => ["libgdk-x11-2.0"],
18433570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gl" => ["libGL"],
18434570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "glu" => ["libGLU"],
18435570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "popt" => ["libpopt"],
18436570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Py" => ["libpython"],
18437570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "jpeg_" => ["libjpeg"],
18438570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "BZ2_" => ["libbz2"],
18439570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Fc" => ["libfontconfig"],
18440570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Xft" => ["libXft"],
18441570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SSL_" => ["libssl"],
18442570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sem_" => ["libpthread"],
18443570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "snd_" => ["libasound"],
18444570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "art_" => ["libart_lgpl_2"],
18445570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dbus_g" => ["libdbus-glib-1"],
18446570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "GOMP_" => ["libgomp"],
18447570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "omp_" => ["libgomp"],
18448570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cms" => ["liblcms"]
18449570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18450570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18451570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Pattern_Lib_Map=(
18452570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SL[a-z]" => ["libslang"]
18453570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18454570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18455570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Symbol_Lib_Map=(
18456570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by name)
18457570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pow" => "libm",
18458570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "fmod" => "libm",
18459570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sin" => "libm",
18460570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "floor" => "libm",
18461570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cos" => "libm",
18462570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dlopen" => "libdl",
18463570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "deflate" => "libz",
18464570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "inflate" => "libz",
18465570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "move_panel" => "libpanel",
18466570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "XOpenDisplay" => "libX11",
18467570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "resize_term" => "libncurses",
184688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "clock_gettime" => "librt",
184698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "crypt" => "libcrypt"
18470570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18471570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18472570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub find_SymbolLibs($$)
18473570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18474570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Symbol) = @_;
18475570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18476570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(index($Symbol, "g_")==0 and $Symbol=~/[A-Z]/)
18477570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # debug symbols
18478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return ();
18479570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18480570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18481570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %Paths = ();
18482570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18483570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $LibName = $Symbol_Lib_Map{$Symbol})
18484570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18485570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Paths{$Path} = 1;
18487570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18488570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18489570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18490570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $SymbolPrefix = getPrefix($Symbol))
18491570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18492570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(defined $Cache{"find_SymbolLibs"}{$SymbolPrefix}) {
18493570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return @{$Cache{"find_SymbolLibs"}{$SymbolPrefix}};
18494570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18495570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18496570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18497570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18498570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(defined $Prefix_Lib_Map{$SymbolPrefix})
18499570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18500570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $LibName (@{$Prefix_Lib_Map{$SymbolPrefix}})
18501570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18502570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18503570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18505570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18506570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18507570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18508570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18509570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18511570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Prefix (sort keys(%Pattern_Lib_Map))
18512570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18513570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Symbol=~/\A$Prefix/)
18514570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18515570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    foreach my $LibName (@{$Pattern_Lib_Map{$Prefix}})
18516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18517570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18518570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                            $Paths{$Path} = 1;
18519570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18520570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18525570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18526570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18527570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($SymbolPrefix)
18528570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # try to find a library by symbol prefix
18529570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($SymbolPrefix eq "inotify" and
18530570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                index($Symbol, "\@GLIBC")!=-1)
18531570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, "libc.$LIB_EXT")) {
18533570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18534570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18535570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18536570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else
18537570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18538570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath_Prefix($LibVersion, $SymbolPrefix)) {
18539570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18540570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18541570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18542570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18543570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18544570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my @Paths = keys(%Paths)) {
18546570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cache{"find_SymbolLibs"}{$SymbolPrefix} = \@Paths;
18547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18548570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18549570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return keys(%Paths);
18550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub get_LibPath_Prefix($$)
18553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Prefix) = @_;
18555570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix = lc($Prefix);
18557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix=~s/[_]+\Z//g;
18558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach ("-2", "2", "-1", "1", "")
18560570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # libgnome-2.so
18561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libxml2.so
18562570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libdbus-1.so
18563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, "lib".$Prefix.$_.".".$LIB_EXT)) {
18564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return $Path;
18565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub getPrefix($)
18571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Str = $_[0];
18573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Str=~/\A([_]*[A-Z][a-z]{1,5})[A-Z]/)
18574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XmuValidArea: Xmu
18575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]+)[A-Z]/)
18578570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # snfReadFont: snf
18579570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18580570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18581570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[A-Z]{2,})[A-Z][a-z]+([A-Z][a-z]+|\Z)/)
18582570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XRRTimes: XRR
18583570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18584570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18585570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]{1,2}\d+)[a-z\d]*_[a-z]+/i)
18586570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # H5HF_delete: H5
18587570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z0-9]{2,}_)[a-z]+/i)
18590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # alarm_event_add: alarm_
18591570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18593570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A(([a-z])\2{1,})/i)
18594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # ffopen
18595570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18596570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18597570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18598570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18599570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
186001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getSymbolSize($$)
186011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # size from the shared library
186021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
186031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0 if(not $Symbol);
186041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Symbol_Library{$LibVersion}{$Symbol}
186051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    and my $LibName = $Symbol_Library{$LibVersion}{$Symbol})
186061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
186071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Library_Symbol{$LibVersion}{$LibName}{$Symbol}
186081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        and my $Size = $Library_Symbol{$LibVersion}{$LibName}{$Symbol})
186091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
186101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Size<0) {
186111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return -$Size;
18612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
186151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0;
18616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1861807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub canonifyName($$)
18619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # make TIFFStreamOpen(char const*, std::basic_ostream<char, std::char_traits<char> >*)
18620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # to be TIFFStreamOpen(char const*, std::basic_ostream<char>*)
1862107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Name, $Type) = @_;
1862207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1862307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # single
1862407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    while($Name=~/([^<>,]+),\s*$DEFAULT_STD_PARMS<([^<>,]+)>\s*/ and $1 eq $3)
18625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $P = $1;
1862707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Name=~s/\Q$P\E,\s*$DEFAULT_STD_PARMS<\Q$P\E>\s*/$P/g;
18628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1862907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1863007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # double
1863107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($Name=~/$DEFAULT_STD_PARMS/)
1863207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
18633e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Type eq "S")
1863407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1863507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortName, $FuncParams) = split_Signature($Name);
1863607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1863707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            foreach my $FParam (separate_Params($FuncParams, 0, 0))
1863807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
1863907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                if(index($FParam, "<")!=-1)
1864007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                {
1864107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $FParam=~s/>([^<>]+)\Z/>/; # remove quals
1864207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    my $FParam_N = canonifyName($FParam, "T");
1864307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    if($FParam_N ne $FParam) {
1864407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                        $Name=~s/\Q$FParam\E/$FParam_N/g;
1864507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    }
1864607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1864707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1864807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1864907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        elsif($Type eq "T")
1865007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1865107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortTmpl, $TmplParams) = template_Base($Name);
1865207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1865307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my @TParams = separate_Params($TmplParams, 0, 0);
18654e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($#TParams>=1)
1865507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
18656e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                my $FParam = $TParams[0];
18657e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                foreach my $Pos (1 .. $#TParams)
18658e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                {
18659e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    my $TParam = $TParams[$Pos];
18660e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    if($TParam=~/\A$DEFAULT_STD_PARMS<\Q$FParam\E\s*>\Z/) {
18661e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                        $Name=~s/\Q$FParam, $TParam\E\s*/$FParam/g;
18662e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    }
1866307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1866407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1866507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1866607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
18667e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($Type eq "S") {
18668e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        return formatName($Name, "S");
18669e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
18670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
18671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18673dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub translateSymbols(@)
18674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = pop(@_);
1867662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my (@MnglNames1, @MnglNames2, @UnmangledNames) = ();
186779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $Symbol (sort @_)
18678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
186799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_Z")==0)
18680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
186819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next if($tr_name{$Symbol});
186829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Symbol=~s/[\@\$]+(.*)\Z//;
186839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames1, $Symbol);
18684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18685570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        elsif(index($Symbol, "?")==0)
18686570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18687570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            next if($tr_name{$Symbol});
186889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames2, $Symbol);
18689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
18691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # not mangled
186929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $tr_name{$Symbol} = $Symbol;
186939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name_gcc{$Symbol} = $Symbol;
186949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name{$LibVersion}{$Symbol} = $Symbol;
18695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames1 > -1)
18698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC names
1869962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames1));
18700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames1)
18701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1870262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1870362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1870472930b9bbe1284ca8eee0f5a2728d5bf094400e5Andrey Ponomarenko                $tr_name{$MnglName} = canonifyName($Unmangled, "S");
1870562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $mangled_name_gcc{$tr_name{$MnglName}}) {
1870662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $mangled_name_gcc{$tr_name{$MnglName}} = $MnglName;
1870762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
187089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($MnglName, "_ZTV")==0
1870962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                and $tr_name{$MnglName}=~/vtable for (.+)/)
1871062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # bind class name and v-table symbol
1871162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $ClassName = $1;
1871262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ClassVTable{$ClassName} = $MnglName;
1871362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $VTableClass{$MnglName} = $ClassName;
1871462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
18715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames2 > -1)
18719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC names
1872062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames2));
18721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames2)
18722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1872362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1872462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
187259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $tr_name{$MnglName} = formatName($Unmangled, "S");
1872662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $mangled_name{$LibVersion}{$tr_name{$MnglName}} = $MnglName;
1872762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
18728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%tr_name;
18731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol($$$)
18734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Deps) = @_;
18736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(link_symbol_internal($Symbol, $RunWith, \%Symbol_Library)) {
18737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Deps eq "+Deps")
18740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check the dependencies
1874162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(link_symbol_internal($Symbol, $RunWith, \%DepSymbol_Library)) {
18742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol_internal($$$)
18749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Where) = @_;
18751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Where or not $Symbol);
18752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Where->{$RunWith}{$Symbol})
18753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # the exact match by symbol name
18754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VSym = $SymVer{$RunWith}{$Symbol})
18757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # indirect symbol version, i.e.
18758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # foo_old and its symlink foo@v (or foo@@v)
187599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # foo_old may be in symtab table
18760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$VSym}) {
18761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
187641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Sym, $Spec, $Ver) = separate_symbol($Symbol);
18765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Sym and $Ver)
18766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for the symbol with the same version
18767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or without version
18768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym})
18769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo@v|foo@@v
18770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo
18771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@".$Ver})
18774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@@v
18775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@v
18776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@\@".$Ver})
18779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@v
18780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@@v
18781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
187871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols_App($)
18788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
187909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $Path);
18791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Imported = ();
187926fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "macos")
18793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1879407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
1879507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if(not $NM) {
1879607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1879807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        open(APP, "$NM -g \"$Path\" 2>\"$TMP_DIR/null\" |");
187999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
188009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
1880107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ U _([\w\$]+)\s*\Z/) {
18802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
188076fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    elsif($OStarget eq "windows")
18808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin.exe\"");
18812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18813a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$DumpBinCmd /IMPORTS \"$Path\" 2>\"$TMP_DIR/null\" |");
188149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
188159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
18816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\s*\w+\s+\w+\s+\w+\s+([\w\?\@]+)\s*/) {
18817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18828f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        open(APP, "$ReadelfCmd -Ws \"$Path\" 2>\"$TMP_DIR/null\" |");
188299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<APP>)
18831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
188329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $symtab)
188339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # do nothing with symtab
188349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($_, "'.dynsym'")!=-1)
188359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # dynamic table
188369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = undef;
188379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
18838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
188399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(index($_, "'.symtab'")!=-1)
188409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # symbol table
188419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $symtab = 1;
18842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
188439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(my @Info = readline_ELF($_))
18844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
188459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my ($Ndx, $Symbol) = ($Info[5], $Info[6]);
188469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
188479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # only imported symbols
188489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    push(@Imported, $Symbol);
18849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Imported;
18855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
188579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_BIND = map {$_=>1} (
188589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "WEAK",
188599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "GLOBAL"
188609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
188619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
188629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_TYPE = map {$_=>1} (
188639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "FUNC",
188649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "IFUNC",
188659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "OBJECT",
188669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COMMON"
188679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
188689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
188699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_VIS = map {$_=>1} (
188709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DEFAULT",
188719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PROTECTED"
188729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
188739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
18874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readline_ELF($)
188759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{ # read the line of 'readelf' output corresponding to the symbol
188769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my @Info = split(/\s+/, $_[0]);
188779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name
188789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
18879fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UND  av_image_fill_pointers@LIBAVUTIL_52 (3)
188809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # spaces
188819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # num
18882fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18883fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Info==7)
18884fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # UND SYMBOL (N)
18885fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Info[7]=~/\(\d+\)/) {
18886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            pop(@Info);
18887fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18888fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
188909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($#Info!=6)
188919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # other lines
188929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
188939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1889474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne "UND");
188959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_BIND{$Info[3]});
188969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_VIS{$Info[4]});
188979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info[5] eq "ABS" and $Info[0]=~/\A0+\Z/)
188989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3
188999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
189009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget eq "symbian")
189029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # _ZN12CCTTokenType4NewLE4TUid3RFs@@ctfinder{000a0000}[102020e5].dll
189039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Info[6], "_._.absent_export_")!=-1)
189049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # "_._.absent_export_111"@@libstdcpp{00010001}[10282872].dll
18905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
18906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
189079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[6]=~s/\@.+//g; # remove version
18908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
189099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($Info[2], "0x") == 0)
189109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # size == 0x3d158
189119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[2] = hex($Info[2]);
189129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return @Info;
18914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
189169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath($$)
189171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
189189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
189199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $LibVersion or not $Name);
189209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"get_LibPath"}{$LibVersion}{$Name}) {
189219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_LibPath"}{$LibVersion}{$Name};
189221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
189239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"get_LibPath"}{$LibVersion}{$Name} = get_LibPath_I($LibVersion, $Name));
189249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
189259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath_I($$)
189279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
189289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
189299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(is_abs($Name))
189301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
189319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Name)
189329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # absolute path
189339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return $Name;
189341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
189359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
189369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # broken
189379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return "";
189389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
189399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1894007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredObjects{$LibVersion}{$Name})
189419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1894207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredObjects{$LibVersion}{$Name};
189439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1894407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredSONAMEs{$LibVersion}{$Name})
189459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1894607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredSONAMEs{$LibVersion}{$Name};
189479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $DefaultPath = $DyLib_DefaultPath{$Name})
189499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # ldconfig default paths
189509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $DefaultPath;
189519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18952570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultLibPaths, @{$SystemPaths{"lib"}})
189539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # search in default linker directories
189549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and then in all system paths
189559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Dir."/".$Name) {
1895674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Dir,$Name);
189571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
189589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18959e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"}) {
18960e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
18961e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
189629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my @AllObjects = keys(%{$SystemObjects{$Name}})) {
189639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $AllObjects[0];
189649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $ShortName = parse_libname($Name, "name+ext", $OStarget))
189669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
189679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($ShortName ne $Name)
189681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # FIXME: check this case
189699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my $Path = get_LibPath($LibVersion, $ShortName)) {
189709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $Path;
189719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
189721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
189731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
189749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    # can't find
189759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "";
189761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
189771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
189789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub readSymbols_Lib($$$$$$)
18979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
189809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Lib_Path, $IsNeededLib, $Weak, $Deps, $Vers) = @_;
189819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $LibVersion or not $Lib_Path);
1898274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1898374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Real_Path = realpath($Lib_Path);
1898474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1898574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $Real_Path)
1898674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # broken link
1898774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return ();
1898874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1898974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1899074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Lib_Name = get_filename($Real_Path);
1899174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
18992fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ExtraInfo)
18993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
1899474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $KnownLibs{$Real_Path} = 1;
18995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $KnownLibs{$Lib_Path} = 1; # links
1899674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1899774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
189989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($IsNeededLib)
189999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CheckedDyLib{$LibVersion}{$Lib_Name}) {
190019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ();
190029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
190039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
190049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(isCyclical(\@RecurLib, $Lib_Name) or $#RecurLib>=1);
19005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CheckedDyLib{$LibVersion}{$Lib_Name} = 1;
1900662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
19007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurLib, $Lib_Name);
19008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Value_Interface, %Interface_Value, %NeededLib) = ();
1900957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    my $Lib_ShortName = parse_libname($Lib_Name, "name+ext", $OStarget);
1901057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko
1901157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(not $IsNeededLib)
1901257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    { # special cases: libstdc++ and libc
1901357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        if(my $ShortName = parse_libname($Lib_Name, "short", $OStarget))
1901457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        {
1901557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            if($ShortName eq "libstdc++")
1901657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libstdc++.so.6
1901757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $STDCXX_TESTING = 1;
1901857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
1901957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            elsif($ShortName eq "libc")
1902057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libc-2.11.3.so
1902157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $GLIBC_TESTING = 1;
1902257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
19023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19025dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $DebugPath = "";
19026a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug and not $DumpSystem)
190271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # debug mode
19028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $DebugPath = $DEBUG_PATH{$LibVersion}."/libs/".get_filename($Lib_Path).".txt";
190291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mkpath(get_dirname($DebugPath));
190301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
19031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "macos")
19032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Mac OS X: *.dylib, *.a
1903307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
190344b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(not $NM) {
190354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
19036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1903707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $NM .= " -g \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19038a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
190391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
190401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
1904107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            system($NM." >\"$DebugPath\"");
190421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
190431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
190441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
190451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
1904607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            open(LIB, $NM." |");
190471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
19048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19050570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($CheckUndefined)
19051570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
19052570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not $IsNeededLib)
19053570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
19054570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(/ U _([\w\$]+)\s*\Z/)
19055570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
1905674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $UndefinedSymbols{$LibVersion}{$Lib_Name}{$1} = 0;
19057570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        next;
19058570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19059570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
19060570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
19061570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1906207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ [STD] _([\w\$]+)\s*\Z/)
19063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19064570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $Symbol = $1;
1906562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1906662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1906757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1906862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
19069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
19070570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
1907162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1907362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19075570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
19076570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
190779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
190789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
19079570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
190809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
190819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
1908707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
190889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
190899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
190909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
190919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
1909207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1909307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                my $OtoolCmd = get_CmdPath("otool");
190944b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                if(not $OtoolCmd) {
190954b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    exitStatus("Not_Found", "can't find \"otool\"");
1909607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1909707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
190989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$OtoolCmd -L \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
190999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
191009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
191019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([\/\\].+\.$LIB_EXT)\s*/
191029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
191039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
191049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
191069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OStarget eq "windows")
19111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Windows *.dll, *.lib
19112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
19113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
19114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
19115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
191161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DumpBinCmd .= " /EXPORTS \"".$Lib_Path."\" 2>$TMP_DIR/null";
19117a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
191181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
191191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19120a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($DumpBinCmd." >\"$DebugPath\"");
191211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
191221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
191231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
191241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
191251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DumpBinCmd." |");
191261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
19127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 1197 4AC 0000A620 SetThreadStackGuarantee
19129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 1198 4AD          SetThreadToken (forwarded to ...)
19130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 3368 _o2i_ECPublicKey
1913154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko          # 1 0 00005B30 ??0?N = ... (with pdb)
1913254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(/\A\s*\d+\s+[a-f\d]+\s+[a-f\d]+\s+([\w\?\@]+)\s*(?:=.+)?\Z/i
19133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+[a-f\d]+\s+([\w\?\@]+)\s*\(\s*forwarded\s+/
1913454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            or /\A\s*\d+\s+_([\w\?\@]+)\s*(?:=.+)?\Z/)
19135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic, static and forwarded symbols
19136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $realname = $1;
1913762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1913862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1913957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1914062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
1914162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$realname} = $Lib_Name;
1914262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
1914362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1914562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$realname} = $Lib_Name;
19148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
191499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
191509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
191519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($realname, "_Z")==0 or index($realname, "?")==0) {
191529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
191539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
19159f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
191609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
191619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
191629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
191639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
191649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$DumpBinCmd /DEPENDENTS \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
191659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
191669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
191679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([^\s]+?\.$LIB_EXT)\s*/i
191689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
191699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{path_format($1, $OSgroup)} = 1;
191709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
191729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Unix; *.so, *.a
19178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Symbian: *.dso, *.lib
19179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
19180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
19181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
19182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19183f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Cmd = $ReadelfCmd." -Ws \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19184a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
191851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
191861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19187f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            system($Cmd." >\"$DebugPath\"");
191881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
191891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
191901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
191911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
19192f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
191931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
191949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
19195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
19198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic library specifics
191999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(defined $symtab)
1920062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
192019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(index($_, "'.dynsym'")!=-1)
1920262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # dynamic table
192039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $symtab = undef;
1920462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
192059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    # do nothing with symtab
192069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next;
19207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(index($_, "'.symtab'")!=-1)
19209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # symbol table
192109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = 1;
19211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
192149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))
19215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # read ELF entry
192169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
19217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # ignore interfaces that are imported from somewhere else
19218570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($CheckUndefined)
19219570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
19220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(not $IsNeededLib) {
1922174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            $UndefinedSymbols{$LibVersion}{$Lib_Name}{$Symbol} = 0;
19222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
19223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19226c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                if($Bind eq "WEAK")
19227c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                {
1922807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $WeakSymbols{$LibVersion}{$Symbol} = 1;
19229c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    if($Weak eq "-Weak")
19230c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    { # skip WEAK symbols
19231c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                        next;
19232c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    }
19233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Short = $Symbol;
192359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Short=~s/\@.+//g;
192369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Type eq "OBJECT")
19237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # global data
19238fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Symbol} = $Size;
19239fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Short} = $Size;
19240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1924162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1924262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1924357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1924462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
192459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
192469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
1924762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1924962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
192519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
192529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
192539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($Vers)
192549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
192559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($LIB_EXT eq "so")
192569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # value
192579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Interface_Value{$LibVersion}{$Symbol} = $Value;
192589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Value_Interface{$LibVersion}{$Value}{$Symbol} = 1;
192599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
192619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
192629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
192639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
192649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
192659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19269f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
19270f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        close(LIB);
19271f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19272f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Deps and $LIB_TYPE eq "dynamic")
19273f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        { # dynamic library specifics
19274f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Cmd = $ReadelfCmd." -Wd \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19275f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
19276f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19277f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            while(<LIB>)
19278f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
19279f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(/NEEDED.+\[([^\[\]]+)\]/)
19280f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # dependencies:
19281f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                  # 0x00000001 (NEEDED) Shared library: [libc.so.6]
19282f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $NeededLib{$1} = 1;
1928362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1928462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19285f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19286f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            close(LIB);
19287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
192899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Vers)
192909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
192919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib and $LIB_EXT eq "so")
192929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # get symbol versions
19293fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %Found = ();
19294fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19295fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # by value
1929674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
192989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
192999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Value = $Interface_Value{$LibVersion}{$Symbol})
19300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
193019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    foreach my $Symbol_SameValue (keys(%{$Value_Interface{$LibVersion}{$Value}}))
19302a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    {
193039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Symbol_SameValue ne $Symbol
193049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        and index($Symbol_SameValue,"\@")==-1)
193059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
193069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $SymVer{$LibVersion}{$Symbol_SameValue} = $Symbol;
19307fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $Found{$Symbol} = 1;
193089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            last;
193099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19310a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
19311fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19312fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19313fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19314fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # default
19315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19316fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19318fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@\@")==-1);
19319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19320fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@\@/
19321fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19322fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19323fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19324fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19325fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19326fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19327fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19328fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # non-default
19329fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19330fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19331fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19332fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
19333fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19334fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@([^\@]*)/
19335fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19336fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19337fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19338fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Deps)
19344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
193459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $DyLib (sort keys(%NeededLib))
193469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19347fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Library_Needed{$LibVersion}{$Lib_Name}{get_filename($DyLib)} = 1;
19348fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1934974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(my $DepPath = get_LibPath($LibVersion, $DyLib))
1935074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1935174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(not $CheckedDyLib{$LibVersion}{get_filename($DepPath)}) {
1935274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    readSymbols_Lib($LibVersion, $DepPath, 1, "+Weak", $Deps, $Vers);
1935374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
193549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurLib);
19358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Library_Symbol{$LibVersion};
19359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
193619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes($)
19362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefixes = ();
193649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    get_prefixes_I([$_[0]], \%Prefixes);
193659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return keys(%Prefixes);
193669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
193679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
193689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes_I($$)
193699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
193709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $P (@{$_[0]})
19371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
193729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my @Parts = reverse(split(/[\/\\]+/, $P));
193739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Name = $Parts[0];
193749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach (1 .. $#Parts)
193759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
193769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $_[1]->{$Name}{$P} = 1;
193779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            last if($_>4 or $Parts[$_] eq "include");
193789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Name = $Parts[$_].$SLASH.$Name;
193799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19383e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenkosub checkSystemFiles()
19384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19385e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $Cache{"checkSystemFiles"} = 1;
19386e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SysHeaders = ();
19388e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19389e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"lib"}})
19390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -d $DevelPath);
19392e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
193932b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        my @Files = cmd_find($DevelPath,"f");
193942b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
193952b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        { # add symbolic links
193962b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if(-f $Link) {
193972b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                push(@Files, $Link);
193982b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
193992b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
19400e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19401ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for headers in /usr/lib
19402ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my @Headers = grep { /\.h(pp|xx)?\Z|\/include\// } @Files;
19403ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        @Headers = grep { not /\/(gcc|jvm|syslinux|kbd|parrot|xemacs|perl|llvm)/ } @Headers;
19404ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, @Headers);
19405e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19406e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        # search for libraries in /usr/lib (including symbolic links)
19407e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Libs = grep { /\.$LIB_EXT[0-9.]*\Z/ } @Files;
19408e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $Path (@Libs)
194099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19410e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            my $N = get_filename($Path);
19411e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{$N}{$Path} = 1;
19412e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{parse_libname($N, "name+ext", $OStarget)}{$Path} = 1;
19413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19415e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19416ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"include"}})
19417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19418ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not -d $DevelPath);
19419ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for all header files in the /usr/include
19420ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # with or without extension (ncurses.h, QtCore, ...)
19421ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, cmd_find($DevelPath,"f"));
19422ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
19423ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # add symbolic links
19424ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(-f $Link) {
19425ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                push(@SysHeaders, $Link);
19426e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            }
19427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19429ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    get_prefixes_I(\@SysHeaders, \%SystemHeaders);
19430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1943262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getSOPaths($)
19433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
194354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    my @Paths = ();
19436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Libs"}))
19437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Dest) {
19439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
19440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Dest = get_abs_path($Dest);
19442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @SoPaths_Dest = getSOPaths_Dest($Dest, $LibVersion);
19443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (@SoPaths_Dest) {
194444b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            push(@Paths, $_);
19445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194474b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    return sort @Paths;
19448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
194508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipLib($$)
19451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
19453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
194541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
194551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$Name}) {
19456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ShortName = parse_libname($Name, "name+ext", $OStarget);
19459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$ShortName}) {
19460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dir (keys(%{$SkipLibs{$LibVersion}{"Path"}}))
19463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Path=~/\Q$Dir\E([\/\\]|\Z)/) {
19465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
194681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipLibs{$LibVersion}{"Pattern"}}))
19469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Name=~/$P/) {
19471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
194731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($P=~/[\/\\]/ and $Path=~/$P/) {
19474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
194808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub specificHeader($$)
194818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
194828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Header, $Spec) = @_;
194838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Header);
194848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
194858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Spec eq "windows")
194868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {# MS Windows
194878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[._-])(win|wince|wnt)(\d\d|[._-]|\Z)/i);
194888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/([._-]w|win)(32|64)/i);
194898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(Win|Windows)[A-Z]/);
194908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(w|win|windows)(32|64|\.)/i);
194918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
194928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win32",
194938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win64",
194948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win",
194958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "windows",
194968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "msvcrt"
194978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        ); # /gsf-win32/
194988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
194998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Header=~/[\/\\](|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
195008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    elsif($Spec eq "macos")
195038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Mac OS
195048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[_-])mac[._-]/i);
195058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
195088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
195098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipAlienHeader($)
195118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
195128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
195138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Path);
195148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = get_dirname($Path);
195158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/2/)
195178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 2 - skip internal headers
195188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Terms = (
195198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "p",
195208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
195218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "int",
195228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
195238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "implementation",
195248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
195258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
195268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
195278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
195288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
195298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test",
195308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "gen"
195318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
195328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
195348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
195358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
195368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "port",
195378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
195388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
195398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "detail",
195408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "details",
195418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
195428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
195438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
195448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "config",
195458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compiler",
195468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "platform",
195478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test"
195488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
195498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $TERMs = join("|", @Terms)) {
195518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Name=~/(\A|[._-])($TERMs)([._-]|\Z)/i);
195528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
195548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Dir=~/(\A|[\/\\])(|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
195558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/[a-z](Imp|Impl|I|P)(\.|\Z)/);
195588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/1/)
195618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 1 - skip non-Linux headers
195628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "windows")
195638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
195648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "windows")) {
195658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
195668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
195678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "macos")
195698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
195708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "macos")) {
195718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
195728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
195738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # valid
195778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
195788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
195798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1958062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader($$)
1958162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1958262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1958362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
1958462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"skipHeader"}{$Path}) {
1958562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"skipHeader"}{$Path};
1958662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
195878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/1|2/)
195888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # --tolerant
195898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(skipAlienHeader($Path)) {
195908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return ($Cache{"skipHeader"}{$Path} = 1);
195918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$SkipHeaders{$LibVersion}})) {
195948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
195958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1959662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"skipHeader"}{$Path} = skipHeader_I(@_));
1959762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1959862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1959962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader_I($$)
19600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # returns:
19601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  1 - if header should NOT be included and checked
19602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  2 - if header should NOT be included, but should be checked
19603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
196041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
196051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(my $Kind = $SkipHeaders{$LibVersion}{"Name"}{$Name}) {
19606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Kind;
19607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19608f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $D (sort {$SkipHeaders{$LibVersion}{"Path"}{$a} cmp $SkipHeaders{$LibVersion}{"Path"}{$b}}
19609f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Path"}}))
19610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
196119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Path, $D)!=-1)
196129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
196139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Path=~/\Q$D\E([\/\\]|\Z)/) {
196149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $SkipHeaders{$LibVersion}{"Path"}{$D};
196159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19618f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $P (sort {$SkipHeaders{$LibVersion}{"Pattern"}{$a} cmp $SkipHeaders{$LibVersion}{"Pattern"}{$b}}
19619f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Pattern"}}))
19620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1962162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Kind = $SkipHeaders{$LibVersion}{"Pattern"}{$P})
1962262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1962362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Name=~/$P/) {
1962462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1962562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1962662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P=~/[\/\\]/ and $Path=~/$P/) {
1962762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1962862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
196318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
19632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
196359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject_Dir($$)
19636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $LibVersion) = @_;
19638570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep {$_ eq $Dir} @{$SystemPaths{"lib"}})
19639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # system directory
19640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
196429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($RegisteredObject_Dirs{$LibVersion}{$Dir})
19643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already registered
19644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (find_libs($Dir,"",1))
19647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
196498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if(skipLib($Path, $LibVersion));
196509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Path, $LibVersion);
19651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
196529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $RegisteredObject_Dirs{$LibVersion}{$Dir} = 1;
196539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
196549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
196559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject($$)
196569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
196579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1965854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
196599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Name = get_filename($Path);
1966007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    $RegisteredObjects{$LibVersion}{$Name} = $Path;
1966101e4122eddc2eef906a8032a358c05476349146fMattias Ellert    if($OStarget=~/linux|bsd|gnu/i)
196622768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    {
196632768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        if(my $SONAME = getSONAME($Path)) {
196642768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko            $RegisteredSONAMEs{$LibVersion}{$SONAME} = $Path;
196652768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        }
196669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1966757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(my $Short = parse_libname($Name, "name+ext", $OStarget)) {
1966857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        $RegisteredObjects_Short{$LibVersion}{$Short} = $Path;
196699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1967054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19671b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(not $CheckedArch{$LibVersion} and -f $Path)
1967254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19673d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $ObjArch = getArch_Object($Path))
1967454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
19675d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            if($ObjArch ne getArch_GCC($LibVersion))
19676d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            { # translation unit dump generated by the GCC compiler should correspond to the input objects
19677d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $CheckedArch{$LibVersion} = 1;
19678d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey 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.");
1967954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1968054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1968154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1968254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko}
1968354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1968454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub getArch_Object($)
1968554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko{
1968654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $Path = $_[0];
1968754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1968854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my %MachineType = (
1968954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "14C" => "x86",
1969054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "8664" => "x86_64",
1969154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "1C0" => "arm",
1969254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "200" => "ia64"
1969354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    );
1969454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19695b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    my %ArchName = (
19696b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:31-bit" => "s390",
19697b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:64-bit" => "s390x",
19698b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common" => "ppc32",
19699b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common64" => "ppc64",
19700b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "i386:x86-64" => "x86_64",
19701b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "mips:3000" => "mips",
19702b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "sparc:v8plus" => "sparcv9"
19703b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    );
19704b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
197056fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "windows")
1970654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1970754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $DumpbinCmd = get_CmdPath("dumpbin");
1970854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $DumpbinCmd) {
1970954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
1971054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1971154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1971254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $DumpbinCmd." /headers \"$Path\"";
1971354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Out = `$Cmd`;
1971454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1971554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/(\w+)\smachine/)
1971654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1971754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(my $Type = $MachineType{uc($1)})
1971854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1971954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                return $Type;
1972054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1972154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1972254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1972301e4122eddc2eef906a8032a358c05476349146fMattias Ellert    elsif($OStarget=~/linux|bsd|gnu/)
1972454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1972554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $ObjdumpCmd = get_CmdPath("objdump");
1972654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $ObjdumpCmd) {
1972754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"objdump\"");
1972854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1972954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1973054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $ObjdumpCmd." -f \"$Path\"";
197316fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko
197326fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        if($OSgroup eq "windows") {
197336fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "set LANG=$LOCALE & ".$Cmd;
197346fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
197356fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        else {
197366fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "LANG=$LOCALE ".$Cmd;
197376fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
197386fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Out = `$Cmd`;
1973954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1974054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/architecture:\s+([\w\-\:]+)/)
1974154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1974254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $Arch = $1;
1974354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch=~s/\:(.+)//)
1974454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1974554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                my $Suffix = $1;
1974654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19747b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                if(my $Name = $ArchName{$Arch.":".$Suffix})
1974854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                {
19749b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                    $Arch = $Name;
1975054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                }
1975154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1975254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19753b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch=~/i[3-6]86/) {
1975454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86";
1975554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1975654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1975754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch eq "x86-64") {
1975854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86_64";
1975954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1976054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19761b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch eq "ia64-elf64") {
19762b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                $Arch = "ia64";
19763b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            }
19764b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
19765d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            return $Arch;
1976654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1976754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1976854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    else
1976954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    { # macos, etc.
1977054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        # TODO
1977154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1977254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1977354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    return undef;
197749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
197759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
197769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSONAME($)
197779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
197789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Path = $_[0];
197799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return if(not $Path);
197809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"getSONAME"}{$Path}) {
197819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"getSONAME"}{$Path};
197829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $ObjdumpCmd = get_CmdPath("objdump");
197849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $ObjdumpCmd) {
197859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"objdump\"");
197869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
19787a914cb546e74ff89ff5038d0a57d6e7032617d80Lénaïc Huard    my $SonameCmd = "$ObjdumpCmd -x \"$Path\" 2>$TMP_DIR/null";
197889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup eq "windows") {
197899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | find \"SONAME\"";
197909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else {
197929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | grep SONAME";
197939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1979454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $SonameInfo = `$SonameCmd`)
1979554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
197969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SonameInfo=~/SONAME\s+([^\s]+)/) {
197979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ($Cache{"getSONAME"}{$Path} = $1);
197989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
197999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
198009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"getSONAME"}{$Path}="");
19801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSOPaths_Dest($$)
19804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dest, $LibVersion) = @_;
198068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(skipLib($Dest, $LibVersion)) {
19807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Dest)
19810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not parse_libname($Dest, "name", $OStarget)) {
19812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "incorrect format of library (should be *.$LIB_EXT): \'$Dest\'");
19813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
198149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Dest, $LibVersion);
198159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject_Dir(get_dirname($Dest), $LibVersion);
19816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Dest);
19817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(-d $Dest)
19819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest=~s/[\/\\]+\Z//g;
1982162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Libs = ();
19822570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(grep { $Dest eq $_ } @{$SystemPaths{"lib"}})
19823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # you have specified /usr/lib as the search directory (<libs>) in the XML descriptor
19824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and the real name of the library by -l option (bz2, stdc++, Xaw, ...)
19825570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"","*".esc($TargetLibraryName)."*.$LIB_EXT*",2))
19826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all files and symlinks that match the name of a library
19827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(get_filename($Path)=~/\A(|lib)\Q$TargetLibraryName\E[\d\-]*\.$LIB_EXT[\d\.]*\Z/i)
19828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
198299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    registerObject($Path, $LibVersion);
1983074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $Libs{realpath($Path)}=1;
19831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for all files and symlinks
19836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (find_libs($Dest,"",""))
19837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
198398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next if(skipLib($Path, $LibVersion));
198409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                registerObject($Path, $LibVersion);
1984174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Libs{realpath($Path)}=1;
19842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OSgroup eq "macos")
19844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # shared libraries on MacOS X may have no extension
19845570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $Path (cmd_find($Dest,"f"))
19846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if(ignore_path($Path));
198488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next if(skipLib($Path, $LibVersion));
19849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(get_filename($Path)!~/\./
19850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    and cmd_file($Path)=~/(shared|dynamic)\s+library/i)
19851850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
198529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        registerObject($Path, $LibVersion);
1985374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $Libs{realpath($Path)}=1;
19854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1985862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return keys(%Libs);
19859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
19861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
198651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isCyclical($$)
198661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
198671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Stack, $Value) = @_;
198681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return (grep {$_ eq $Value} @{$Stack});
19869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19871d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getGCC_Opts($)
19872d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19873d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19874d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19875d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my @Opts = ();
19876d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19877d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($CompilerOptions{$LibVersion})
19878d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # user-defined options
19879d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $CompilerOptions{$LibVersion});
19880d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19881d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GccOptions)
19882d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # additional
19883d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $GccOptions);
19884d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19885d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19886d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(@Opts) {
19887d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return join(" ", @Opts);
19888d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19889d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19890d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return undef;
19891d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19892d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19893b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenkosub getArch_GCC($)
19894d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{
19895d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19896d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19897d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(defined $Cache{"getArch_GCC"}{$LibVersion}) {
19898d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return $Cache{"getArch_GCC"}{$LibVersion};
19899d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19900d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19901d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Arch = undef;
19902d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19903d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
19904d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    {
19905d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        writeFile("$TMP_DIR/test.c", "int main(){return 0;}\n");
19906d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19907d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." test.c -o test";
19908d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
19909d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
19910d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
19911d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
19912d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19913d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
19914d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        system($Cmd);
19915d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
19916d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19917d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $Arch = getArch_Object("$TMP_DIR/test");
19918d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19919d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test.c");
19920d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test");
19921d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19922d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19923d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Arch) {
19924d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check ARCH type");
19925d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19926d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19927d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return ($Cache{"getArch_GCC"}{$LibVersion} = $Arch);
19928d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19929d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1993054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub detectWordSize($)
19931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1993254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $LibVersion = $_[0];
1993354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19934d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Size = undef;
19935d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19936d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    # speed up detection
1993754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $Arch = getArch($LibVersion))
1993854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19939b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        if($Arch=~/\A(x86_64|s390x|ppc64|ia64|alpha)\Z/) {
19940d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "8";
19941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19942d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        elsif($Arch=~/\A(x86|s390|ppc32)\Z/) {
19943d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "4";
19944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19946d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19947d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
1994854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1994954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        writeFile("$TMP_DIR/empty.h", "");
19950d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19951d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." -E -dD empty.h";
19952d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
19953d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
19954d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
19955d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
19956d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19957d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
19958d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Defines = `$Cmd`;
19959d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
19960d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1996154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        unlink("$TMP_DIR/empty.h");
1996254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1996354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/)
1996454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 4
19965d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = $1;
1996654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1996754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/)
1996854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 3
1996954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $PTRDIFF = $1;
1997054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($PTRDIFF=~/long/) {
19971d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "8";
1997254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1997354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            else {
19974d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "4";
1997554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1997654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
19977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1997854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19979d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Size) {
19980d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check WORD size");
19981d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19982d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19983d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return $Size;
19984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19986d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getWordSize($)
19987d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19988f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return $WORD_SIZE{$_[0]};
19989f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
19990f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
19991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub majorVersion($)
19992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V = $_[0];
19994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $V);
19995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VParts = split(/\./, $V);
19996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VParts[0];
19997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVersions($$)
200001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # compare two versions in dotted-numeric format
20001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($V1, $V2) = @_;
20002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if($V1 eq $V2);
20003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V1Parts = split(/\./, $V1);
20004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V2Parts = split(/\./, $V2);
20005570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
20006570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
20007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
20008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
20009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return -1 if($#V1Parts < $#V2Parts);
20011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#V1Parts > $#V2Parts);
20012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
20013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_ABI_Dump($$)
20016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
20019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FilePath = "";
200209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(isDump_U($Path))
20021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi
20022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = $Path;
20023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi.tar.gz
20026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = unpackDump($Path);
200279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not isDump_U($FilePath)) {
200289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
200299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20031850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2003201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ABI = {};
20033850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2003401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Line = readLineNum($FilePath, 0);
2003501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Line=~/xml/)
2003601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # XML format
2003701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        loadModule("XmlDump");
2003801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = readXmlDump($FilePath);
20039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2004001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    else
2004101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # Perl Data::Dumper format (default)
2004201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        open(DUMP, $FilePath);
2004301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        local $/ = undef;
2004401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $Content = <DUMP>;
2004501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        close(DUMP);
2004601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2004701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(get_dirname($FilePath) eq $TMP_DIR."/unpack")
2004801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # remove temp file
2004901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            unlink($FilePath);
2005001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2005101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Content!~/};\s*\Z/) {
2005201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
2005301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2005401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = eval($Content);
2005501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $ABI) {
2005601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
2005701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # new dumps (>=1.22) have a personal versioning
20060570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $DVersion = $ABI->{"ABI_DUMP_VERSION"};
2006101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ToolVersion = $ABI->{"ABI_COMPLIANCE_CHECKER_VERSION"};
20062570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $DVersion)
20063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old dumps (<=1.21.6) have been marked by the tool version
20064570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $DVersion = $ToolVersion;
20065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20066570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $UsedDump{$LibVersion}{"V"} = $DVersion;
2006752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $UsedDump{$LibVersion}{"M"} = $ABI->{"LibraryName"};
20068fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2006999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    if($ABI->{"PublicABI"}) {
2007099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        $UsedDump{$LibVersion}{"Public"} = 1;
2007199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    }
2007299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko
20073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ABI->{"ABI_DUMP_VERSION"})
20074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
20075570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(cmpVersions($DVersion, $ABI_DUMP_VERSION)>0)
20076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
20077570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $ABI_DUMP_VERSION)");
20078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20080fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
20081fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20082fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(cmpVersions($DVersion, $TOOL_VERSION)>0)
20083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
20084570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $TOOL_VERSION)");
20085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
200876ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko
20088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(majorVersion($DVersion)<2)
200896ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
200906ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (allowed only 2.0<=V<=$ABI_DUMP_VERSION)");
20091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20092fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20093fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"ABI_DUMPER_VERSION"})
20094fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # DWARF ABI Dump
20095fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"P"} = 1;
20096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"R"} = 0; # not implemented yet
20097fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UsedDump{$LibVersion}{"DWARF"} = 1;
20099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2010015bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        if(not $TargetComponent_Opt)
2010115bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        {
2010215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            if($ABI->{"LibraryName"}=~/\.ko[\.\d]*\Z/) {
2010315bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TargetComponent = "module";
2010415bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            }
2010515bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            else {
2010615bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko                $TargetComponent = "object";
2010715bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko            }
2010815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        }
20109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20110fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
201115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.11"))
201125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # old ABI dumps
201135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
201141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2011501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    elsif($ABI->{"BinOnly"})
201161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # ABI dump created with --binary option
201171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
201181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
201195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
201205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # default
201215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"SrcBin"} = 1;
201225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
20123fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2012401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $ABI->{"Mode"}
2012501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    and $ABI->{"Mode"} eq "Extended")
20126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
20127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ExtendedCheck = 1;
20128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2012974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ABI->{"Extra"}) {
2013074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ExtraDump = 1;
2013174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2013274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2013301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Lang = $ABI->{"Language"})
20134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UsedDump{$LibVersion}{"L"} = $Lang;
20136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        setLanguage($LibVersion, $Lang);
20137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2013862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2013901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeInfo{$LibVersion} = $ABI->{"TypeInfo"};
2014062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2014162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
20142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2014301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $TInfo = $ABI->{"TypeInfo"};
2014462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TInfo)
2014562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for older ABI dumps
2014601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TInfo = $ABI->{"TypeDescr"};
2014762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2014862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Tid_TDid = ();
2014962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TDid (keys(%{$TInfo}))
2015062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2015162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TInfo->{$TDid}}))
2015262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2015362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $Tid if($Tid>$MAX_ID);
2015462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $TDid if($TDid and $TDid>$MAX_ID);
20155177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Tid_TDid{$Tid}{$TDid} = 1;
2015662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2015762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2015862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %NewID = ();
2015962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%Tid_TDid))
2016062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2016162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @TDids = keys(%{$Tid_TDid{$Tid}});
2016262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($#TDids>=1)
2016362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2016462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $TDid (@TDids)
2016562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
2016662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TDid) {
2016762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
2016862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
2016962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
2017062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
20171177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $ID = ++$MAX_ID;
20172177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20173177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $NewID{$TDid}{$Tid} = $ID;
20174177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$ID}} = %{$TInfo->{$TDid}{$Tid}};
20175177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeInfo{$LibVersion}{$ID}{"Tid"} = $ID;
2017662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
2017762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2017862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2017962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
2018062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2018162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TDid = $TDids[0];
2018262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
2018362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2018462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2018562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
2018662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2018762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Info = %{$TypeInfo{$LibVersion}{$Tid}};
2018862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $Info{"BaseType"})
2018962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2019062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Bid = $Info{"BaseType"}{"Tid"};
2019162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BDid = $Info{"BaseType"}{"TDid"};
2019262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $BDid="" if(not defined $BDid);
20193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{"BaseType"}{"TDid"});
2019462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(defined $NewID{$BDid} and my $ID = $NewID{$BDid}{$Bid}) {
20195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$Tid}{"BaseType"} = $ID;
2019662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2019762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2019862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TDid"});
2019962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2020101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Machine_DumpInfo($ABI, $LibVersion);
2020201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymbolInfo{$LibVersion} = $ABI->{"SymbolInfo"};
20203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion})
20204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2020501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$LibVersion} = $ABI->{"FuncDescr"};
20206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
20208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validation of old-version dumps
20209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck) {
20210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Invalid_Dump", "the input dump d$LibVersion is invalid");
20211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2021362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2021401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $DepLibrary_Symbol{$LibVersion} = $ABI->{"DepSymbols"};
20215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2021662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
2021762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2021801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $DepSymbols = $ABI->{"DepSymbols"};
2021962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols) {
2022001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $DepSymbols = $ABI->{"DepInterfaces"};
2022162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2022262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols)
2022362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # Cannot reconstruct DepSymbols. This may result in false
2022462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # positives if the old dump is for library 2. Not a problem if
2022562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # old dumps are only from old libraries.
2022662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbols = {};
2022762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2022862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepSymbols})) {
2022962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = 1;
2023062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2023201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymVer{$LibVersion} = $ABI->{"SymbolVersion"};
20233d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
20234d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if(my $V = $TargetVersion{$LibVersion}) {
20235d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $V;
20236d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
20237d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    else {
20238d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $ABI->{"LibraryVersion"};
20239d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
20240d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
20241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipTypes{$LibVersion})
2024299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    { # if not defined by -skip-types option
2024399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(defined $ABI->{"SkipTypes"})
2024499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        {
2024599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            foreach my $TName (keys(%{$ABI->{"SkipTypes"}}))
2024699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            {
2024799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko                $SkipTypes{$LibVersion}{$TName} = 1;
2024899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            }
2024999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2025099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(defined $ABI->{"OpaqueTypes"})
2025199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        { # support for old dumps
2025299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            foreach my $TName (keys(%{$ABI->{"OpaqueTypes"}}))
2025399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            {
2025499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko                $SkipTypes{$LibVersion}{$TName} = 1;
2025599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            }
2025699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
20257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20258ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
20259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
20260ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -skip-symbols option
20261ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"SkipSymbols"};
20262ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $SkipSymbols{$LibVersion})
20263ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
20264ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"SkipInterfaces"};
20265ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
20266ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $SkipSymbols{$LibVersion})
20267ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
20268ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"InternalInterfaces"};
20269ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
20270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2027101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipNameSpaces{$LibVersion} = $ABI->{"SkipNameSpaces"};
20272ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
20273ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if(not $TargetHeaders{$LibVersion})
20274ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -headers-list option
20275ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $TargetHeaders{$LibVersion} = $ABI->{"TargetHeaders"};
20276ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
20277ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
2027801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Path (keys(%{$ABI->{"SkipHeaders"}}))
20279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2028001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = $ABI->{"SkipHeaders"}{$Path};
20281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2028201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = $ABI->{"SkipHeaders"}{$Path};
20283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
202842c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
20285fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    read_Source_DumpInfo($ABI, $LibVersion);
2028601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Libs_DumpInfo($ABI, $LibVersion);
202872c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
202885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.10.1")
202895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    or not $TargetHeaders{$LibVersion})
20290850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # support for old ABI dumps: added target headers
20291850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
202923e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
202942c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
202952c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        if(not $ABI->{"PublicABI"})
202962c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        {
202972c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko            foreach (keys(%{$Registered_Sources{$LibVersion}})) {
202982c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
202992c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko            }
20300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2030201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Constants{$LibVersion} = $ABI->{"Constants"};
20303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"GccConstants"})
20304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # 3.0
20305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Name (keys(%{$ABI->{"GccConstants"}})) {
20306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Constants{$LibVersion}{$Name}{"Value"} = $ABI->{"GccConstants"}{$Name};
20307fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20308fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20309fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2031001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $NestedNameSpaces{$LibVersion} = $ABI->{"NameSpaces"};
20311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $NestedNameSpaces{$LibVersion})
20312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
20313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Cannot reconstruct NameSpaces. This may affect design
20314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # of the compatibility report.
20315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $NestedNameSpaces{$LibVersion} = {};
20316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # target system type
20318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # needed to adopt HTML report
20319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DumpSystem)
20320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # to use in createSymbolsList(...)
2032101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $OStarget = $ABI->{"Target"};
20322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # recreate environment
20324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$Library_Symbol{$LibVersion}}))
20325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2032662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
20327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2032862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2032962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol}<=-1)
20330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # data marked as -size in the dump
20331fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $GlobalDataObject{$LibVersion}{$Symbol} = -$Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol};
20332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
203339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($COMMON_LANGUAGE{$LibVersion} ne "C++")
203349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
203359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
203369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    setLanguage($LibVersion, "C++");
203379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
20338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2034162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$DepLibrary_Symbol{$LibVersion}}))
2034262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2034362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepLibrary_Symbol{$LibVersion}{$Lib_Name}})) {
2034462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2034562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2034662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2034762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VFunc = ();
203491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20351f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
2035262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2035362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Symbol_Library{$LibVersion}{$MnglName}
2035462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $DepSymbol_Library{$LibVersion}{$MnglName}) {
2035562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@VFunc, $MnglName);
2035662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
20357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(@VFunc, $LibVersion);
20360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2036162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
2036262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20363fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not checkDump($LibVersion, "3.0"))
20364fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20365fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20366fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
20367fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseType = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
20368fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
20369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(ref($BaseType) eq "HASH") {
20370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"}{"Tid"};
20371fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
20372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
20373fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20374fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20375fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20376177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not checkDump($LibVersion, "3.2"))
20377177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # support for old ABI dumps
20378177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20379177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20380177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"})
20381177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20382177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Offset (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"VTable"}})) {
20383177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset} = simplifyVTable($TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset});
20384177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
20385177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20386177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20387177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20388177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # repair target headers list
20389177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TargetHeaders{$LibVersion});
20390177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
203913e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
203923e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        }
203933e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
203943e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20395177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # non-target constants from anon enums
20398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Name (keys(%{$Constants{$LibVersion}}))
20399177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20400177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $ExtraDump
20401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not is_target_header($Constants{$LibVersion}{$Name}{"Header"}, $LibVersion))
20402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($Constants{$LibVersion}{$Name});
20404177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
20407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2040874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not checkDump($LibVersion, "2.20"))
2040974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # support for old ABI dumps
2041074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2041174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2041274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2041374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2041474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum|Typedef/)
2041574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # repair complex types first
2041674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                next;
2041774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2041874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
20419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseId = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
2042074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
2042174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $BType = lc($TypeInfo{$LibVersion}{$BaseId}{"Type"});
2042274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($BType=~/Struct|Union|Enum/i)
2042374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2042474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"};
2042574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Name"}=~s/\A\Q$BName\E\b/$BType $BName/g;
2042674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
2042774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2042874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2042974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2043074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2043174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2043274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
2043374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum/) {
2043474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Name"} = lc($TType)." ".$TName;
2043574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2043674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2043774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2043874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2043962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20440dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko    { # NOTE: order is important
2044162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"})
2044262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for old ABI dumps < 2.0 (ACC 1.22)
2044362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $BId (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}}))
2044462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2044562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Access = $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}{$BId})
20446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2044762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Access ne "public") {
2044862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId}{"access"} = $Access;
20449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
20450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2045162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId} = {};
2045262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2045362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseClass"});
2045462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
204559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $TypeInfo{$LibVersion}{$TypeId}{"Header"})
204569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
204579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = path_format($Header, $OSgroup);
204589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $TypeInfo{$LibVersion}{$TypeId}{"Source"})
20460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = $Source;
20462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
2046301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not defined $TypeInfo{$LibVersion}{$TypeId}{"Tid"}) {
2046401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Tid"} = $TypeId;
2046501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20466dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko
20467dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko        # support for old formatting of type names
20468dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko        $TypeInfo{$LibVersion}{$TypeId}{"Name"} = formatName($TypeInfo{$LibVersion}{$TypeId}{"Name"}, "T");
20469dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko
2047062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %TInfo = %{$TypeInfo{$LibVersion}{$TypeId}};
2047162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TInfo{"Base"})
2047262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
204731b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            foreach my $SubId (keys(%{$TInfo{"Base"}}))
204741b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko            {
204751b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                if($SubId eq $TypeId)
204761b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                { # Fix erroneus ABI dump
204771b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$TypeId}{"Base"}{$SubId});
204781b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                    next;
204791b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                }
204801b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko
204811b597c3d39a3d4c9ae37f618a0db277021d56c95Andrey Ponomarenko                $Class_SubClasses{$LibVersion}{$SubId}{$TypeId} = 1;
2048262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2048362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2048401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($TInfo{"Type"} eq "MethodPtr")
2048501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
2048601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(defined $TInfo{"Param"})
2048701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # support for old ABI dumps <= 1.17
2048801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(not defined $TInfo{"Param"}{"0"})
2048901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                {
2049001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Max = keys(%{$TInfo{"Param"}});
2049101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    foreach my $Pos (1 .. $Max) {
2049201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TInfo{"Param"}{$Pos-1} = $TInfo{"Param"}{$Pos};
2049301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2049401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    delete($TInfo{"Param"}{$Max});
2049501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$TypeId}} = %TInfo;
2049601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2049701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2049801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20499fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"BaseType"} eq $TypeId)
20500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # fix ABI dump
20501fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseType"});
20502fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20503dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko
20504fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"Type"} eq "Typedef" and not $TInfo{"Artificial"})
2050562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
20506fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BTid = $TInfo{"BaseType"})
2050762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2050862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BName = $TypeInfo{$LibVersion}{$BTid}{"Name"};
2050962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $BName)
2051062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # broken type
2051162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2051262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2051362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TInfo{"Name"} eq $BName)
2051462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # typedef to "class Class"
205158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                  # should not be registered in TName_Tid
2051662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2051762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2051862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}}) {
2051962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}} = $BName;
2052062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
20521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2052262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2052362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TName_Tid{$LibVersion}{$TInfo{"Name"}})
2052462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # classes: class (id1), typedef (artificial, id2 > id1)
20525dfd124548b3439a0a40764128a7f6506f68ab4eeAndrey Ponomarenko            $TName_Tid{$LibVersion}{$TInfo{"Name"}} = $TypeId;
2052662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2052762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2052862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2052962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.15"))
2053062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2053162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Dups = ();
2053262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
2053362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2053462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
20535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2053662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not defined $TypeInfo{$LibVersion}{$ClassId})
2053762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # remove template decls
2053862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    delete($SymbolInfo{$LibVersion}{$InfoId});
2053962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
20540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20542b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $MName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
20543b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not $MName and $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
2054462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
2054562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($SymbolInfo{$LibVersion}{$InfoId});
20546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20550f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20551f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
20552ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if(my $Class = $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
20553ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Static"}
20554ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
20555ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # support for old ABI dumps (< 3.1)
20556ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if(not defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
20557ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            or $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
20558ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            { # add "this" first parameter
20559ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $ThisTid = getTypeIdByName($TypeInfo{$LibVersion}{$Class}{"Name"}."*const", $LibVersion);
20560ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my %PInfo = ("name"=>"this", "type"=>"$ThisTid");
20561ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20562ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
20563ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                {
20564ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    my @Pos = sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
20565ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    foreach my $Pos (reverse(0 .. $#Pos)) {
20566ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos+1}} = %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos}};
20567ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    }
20568ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                }
20569ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{"0"} = \%PInfo;
20570ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            }
20571ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
20572ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20573f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(not $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
20574f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # ABI dumps have no mangled names for C-functions
20575f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
20576f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
205779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $SymbolInfo{$LibVersion}{$InfoId}{"Header"})
205789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
205799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = path_format($Header, $OSgroup);
205809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20581fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $SymbolInfo{$LibVersion}{$InfoId}{"Source"})
20582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = $Source;
20584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20585f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
20586f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Dump"} = 1;
20588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Machine_DumpInfo($$)
20591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2059201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
2059301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"Arch"}) {
2059401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $CPU_ARCH{$LibVersion} = $ABI->{"Arch"};
20595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2059601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"WordSize"}) {
2059701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"WordSize"};
20598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2060101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"SizeOfPointer"};
20602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $WORD_SIZE{$LibVersion})
20604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps (<1.23)
20605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Tid = getTypeIdByName("char*", $LibVersion))
20606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # size of char*
2060762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WORD_SIZE{$LibVersion} = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PSize = 0;
2061262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
20613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2061462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeInfo{$LibVersion}{$Tid}{"Type"} eq "Pointer")
2061562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # any "pointer"-type
2061662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $PSize = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
20618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($PSize)
20621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # a pointer type size
20622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $WORD_SIZE{$LibVersion} = $PSize;
20623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("WARNING", "cannot identify a WORD size in the ABI dump (too old format)");
20626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2062901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"GccVersion"}) {
2063001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $GCC_VERSION{$LibVersion} = $ABI->{"GccVersion"};
20631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Libs_DumpInfo($$)
20635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2063601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
206379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $Library_Symbol{$LibVersion} = $ABI->{"Symbols"};
206389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $Library_Symbol{$LibVersion})
206399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # support for old dumps
206409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Library_Symbol{$LibVersion} = $ABI->{"Interfaces"};
206419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
20642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Library_Symbol{$LibVersion}})
20643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Libs"} = "OK";
20645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20648fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub read_Source_DumpInfo($$)
20649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2065001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
20651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2065201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%{$ABI->{"Headers"}})
20653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Headers"} = "OK";
20655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2065601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Identity (sort {$ABI->{"Headers"}{$a}<=>$ABI->{"Headers"}{$b}} keys(%{$ABI->{"Headers"}}))
206576ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Identity"} = $Identity;
2065901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Pos"} = $ABI->{"Headers"}{$Identity};
20660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(keys(%{$ABI->{"Sources"}})
20663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not $DumpAPI) {
20664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{$LibVersion}{"Sources"} = "OK";
20665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (sort {$ABI->{"Sources"}{$a}<=>$ABI->{"Sources"}{$b}} keys(%{$ABI->{"Sources"}}))
206676ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Identity"} = $Name;
20669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Pos"} = $ABI->{"Headers"}{$Name};
20670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_libs($$$)
20674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Type, $MaxDepth) = @_;
20676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # FIXME: correct the search pattern
206778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return cmd_find($Path, $Type, '\.'.$LIB_EXT.'[0-9.]*\Z', $MaxDepth, 1);
20678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createDescriptor($$)
20681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $LibVersion or not $Path
20684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -e $Path) {
20685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
20686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-d $Path)
20688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory with headers files and shared objects
20689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "
20690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <version>
20691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ".$TargetVersion{$LibVersion}."
20692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </version>
20693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <headers>
20695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </headers>
20697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <libs>
20699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </libs>";
20701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # files
207049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Path=~/\.(xml|desc)\Z/i)
20705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(is_header($Path, 2, $LibVersion))
20709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # header file
20710ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckHeadersOnly = 1;
20711ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20712ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==1) {
20713ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "X";
20714ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20715ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20716ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==2) {
20717ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "Y";
20718ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20719ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lib_default_paths()
20741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LPaths = ();
20743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "bsd")
20744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20745a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20746a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
20747a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -r 2>\"$TMP_DIR/null\"`))
20748a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
2074974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/\A[ \t]*\d+:\-l(.+) \=\> (.+)\Z/)
2075074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2075174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $Name = "lib".$1;
2075274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name}) {
2075374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $2;
2075474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
20759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $OSgroup eq "linux")
20767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # use host (x86) ldconfig with the target (arm) ld.so.conf
20768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-e $SystemRoot."/etc/ld.so.conf") {
20769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LdConfig .= " -f ".$SystemRoot."/etc/ld.so.conf";
20770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20772a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -p 2>\"$TMP_DIR/null\"`))
20773a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
20774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A[ \t]*([^ \t]+) .* \=\> (.+)\Z/)
20775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Name, $Path) = ($1, $2);
20777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path=~s/[\/]{2,}/\//;
2077874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name})
2077974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    { # get first element from the list of available paths
2078074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2078174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2078274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib/i386-linux-gnu/libstdc++.so.6
2078374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
2078474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2078574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $Path;
2078674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2079082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko        elsif($OSgroup eq "linux") {
20791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%LPaths;
20795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_bin_default_paths()
20798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $EnvPaths = $ENV{"PATH"};
20800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos") {
20801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $EnvPaths.=":".$ENV{"BETOOLS"};
20802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Sep = ($OSgroup eq "windows")?";":":|;";
20804570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (split(/$Sep/, $EnvPaths))
20805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
20807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Path);
20808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot
20809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\A\Q$SystemRoot\E\//)
20810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT use binaries from target system
20811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20813570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U(\@DefaultBinPaths, $Path);
20814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_inc_default_paths()
20818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20819570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %DPaths = ("Cpp"=>[],"Gcc"=>[],"Inc"=>[]);
20820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
20821a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $Line (split(/\n/, `$GCC_PATH -v -x c++ -E \"$TMP_DIR/empty.h\" 2>&1`))
208221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting GCC default include paths
20823570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        next if(index($Line, "/cc1plus ")!=-1);
20824570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~/\A[ \t]*((\/|\w+:\\).+)[ \t]*\Z/)
20826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2082774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Path = realpath($1);
20828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = path_format($Path, $OSgroup);
20829570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Path, "c++")!=-1
20830570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            or index($Path, "/g++/")!=-1)
20831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20832570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Cpp"}, $Path);
20833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $MAIN_CPP_DIR
20834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or get_depth($MAIN_CPP_DIR)>get_depth($Path)) {
20835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MAIN_CPP_DIR = $Path;
20836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20838570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            elsif(index($Path, "gcc")!=-1) {
20839570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Gcc"}, $Path);
20840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20843570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Path=~/local[\/\\]+include/)
20844570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # local paths
20845570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    next;
20846570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $Path!~/\A\Q$SystemRoot\E(\/|\Z)/)
20849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # The GCC include path for user headers is not a part of the system root
20850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # The reason: you are not specified the --cross-gcc option or selected a wrong compiler
20851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # or it is the internal cross-GCC path like arm-linux-gnueabi/include
20852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20854570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Inc"}, $Path);
20855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
20859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %DPaths;
20860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_default_paths($)
20863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($HSearch, $LSearch, $BSearch, $GSearch) = (1, 1, 1, 1);
20865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Search = $_[0];
20866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/inc/) {
20867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/lib/) {
20870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/bin/) {
20873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $BSearch = 0;
20874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/gcc/) {
20876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GSearch = 0;
20877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20878570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"include"}})
20879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20883570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"lib"}})
208846fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    { # <search_libs> section of the XML descriptor
208856fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko      # do NOT search for systems libraries
20886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (keys(%{$OS_AddPath{$OSgroup}}))
20889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # additional search paths
20890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "include" and not $HSearch);
20891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "lib" and not $LSearch);
20892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "bin" and not $BSearch);
20893570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{$Type}, grep { -d $_ } @{$OS_AddPath{$OSgroup}{$Type}});
20894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
20896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unix-like
20897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Type ("include", "lib", "bin")
20898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # automatic detection of system "devel" directories
20899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "include" and not $HSearch);
20900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "lib" and not $LSearch);
20901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "bin" and not $BSearch);
20902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($UsrDir, $RootDir) = ("/usr", "/");
20903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $Type ne "bin")
20904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 1. search for target headers and libraries
20905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # 2. use host commands: ldconfig, readelf, etc.
20906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($UsrDir, $RootDir) = ("$SystemRoot/usr", $SystemRoot);
20907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20908570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U($SystemPaths{$Type}, cmd_find($RootDir,"d","*$Type*",1));
20909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-d $RootDir."/".$Type)
20910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if "/lib" is symbolic link
20911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($RootDir eq "/") {
20912570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, "/".$Type);
20913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
20915570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $RootDir."/".$Type);
20916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20918570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(-d $UsrDir)
20919570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
20920570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{$Type}, cmd_find($UsrDir,"d","*$Type*",1));
20921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-d $UsrDir."/".$Type)
20922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # if "/usr/lib" is symbolic link
20923570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $UsrDir."/".$Type);
20924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_bin_default_paths();
20931570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, @DefaultBinPaths);
20932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check environment variables
20934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos")
20935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
209364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        foreach (my @Paths = @{$SystemPaths{"bin"}})
20937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
209384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($_ eq ".") {
209394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                next;
209404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
209414b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            # search for /boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-101111/bin/
209424b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my @Dirs = sort cmd_find($_, "d", "bin")) {
209434b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                push_U($SystemPaths{"bin"}, sort {get_depth($a)<=>get_depth($b)} @Dirs);
20944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HSearch)
20947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20948570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultIncPaths, grep { is_abs($_) } (
20949570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BEINCLUDES"})
20950570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LSearch)
20953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20954570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, grep { is_abs($_) } (
20955570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BELIBRARIES"}),
20956570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"LIBRARY_PATH"})
20957570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LSearch)
20961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # using linker to get system paths
20962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LPaths = detect_lib_default_paths())
20963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # unix-like
20964570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Dirs = ();
20965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Name (keys(%{$LPaths}))
20966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $LPaths->{$Name}!~/\A\Q$SystemRoot\E\//)
20969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # wrong ldconfig configuration
20970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # check your <sysroot>/etc/ld.so.conf
20971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DyLib_DefaultPath{$Name} = $LPaths->{$Name};
20974570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Dir = get_dirname($LPaths->{$Name})) {
20975570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Dirs{$Dir} = 1;
20976570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20978570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, sort {get_depth($a)<=>get_depth($b)} sort keys(%Dirs));
20979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20980570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, @DefaultLibPaths);
20981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc)
20985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --cross-gcc=arm-linux-gcc
20986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-e $CrossGcc)
20987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # absolute or relative path
20988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = get_abs_path($CrossGcc);
20989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($CrossGcc!~/\// and get_CmdPath($CrossGcc))
20991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # command name
20992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = $CrossGcc;
20993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$CrossGcc\'");
20996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GCC_PATH=~/\s/) {
20998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = "\"".$GCC_PATH."\"";
20999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GSearch)
21003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC path and default include dirs
21004570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CrossGcc)
21005570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # try default gcc
21006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $GCC_PATH = get_CmdPath("gcc");
21007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2100801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $GCC_PATH)
2100901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to find gcc-X.Y
21010570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (@{$SystemPaths{"bin"}})
2101101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
210128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my @GCCs = cmd_find($Path, "", '/gcc-[0-9.]*\Z', 1, 1))
2101301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                { # select the latest version
2101401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    @GCCs = sort {$b cmp $a} @GCCs;
2101501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    if(check_gcc($GCCs[0], "3"))
2101601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    {
2101701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $GCC_PATH = $GCCs[0];
2101801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        last;
2101901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2102001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2102101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2102201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GCC_PATH) {
21024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find GCC>=3.0 in PATH");
21025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21026f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
210278a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        my $GCC_Ver = get_dumpversion($GCC_PATH);
210288a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($GCC_Ver eq "4.8")
210298a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        { # on Ubuntu -dumpversion returns 4.8 for gcc 4.8.4
210308a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            my $Info = `$GCC_PATH --version`;
210318a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
210328a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            if($Info=~/gcc\s+(|\([^()]+\)\s+)(\d+\.\d+\.\d+)/)
210338a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            { # gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
210348a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko              # gcc (GCC) 4.9.2 20150212 (Red Hat 4.9.2-6)
210358a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                $GCC_Ver = $2;
210368a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko            }
210378a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        }
210388a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
210398a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko        if($GCC_Ver)
21040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21041ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $GccTarget = get_dumpmachine($GCC_PATH);
21042ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21043ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GccTarget=~/linux/)
21044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21045ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "linux";
21046ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
21047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21048ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            elsif($GccTarget=~/symbian/)
21049ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            {
21050ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "symbian";
21051ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
21052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21053ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21054ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget, target: ".getArch_GCC(1).")");
21055ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21056ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            # check GCC version
21057ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GCC_Ver=~/\A4\.8(|\.[012])\Z/)
21058ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57850
210598a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko              # introduced in 4.8 and fixed in 4.8.3
210608a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko                printMsg("WARNING", "Not working properly with GCC $GCC_Ver. Please update GCC to 4.8.3 or downgrade it to 4.7. You can use a local GCC installation by --gcc-path=PATH option.");
210618a4c3f8b1d2f4488f10fecb372880d3b78cc3497Andrey Ponomarenko
21062ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $EMERGENCY_MODE_48 = 1;
21063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21065ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
21066ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "something is going wrong with the GCC compiler");
21067ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
21068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HSearch)
21070ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
21071ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # GCC standard paths
21072ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($GCC_PATH and not $NoStdInc)
21073ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
21074ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my %DPaths = detect_inc_default_paths();
21075ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultCppPaths = @{$DPaths{"Cpp"}};
21076ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultGccPaths = @{$DPaths{"Gcc"}};
21077ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultIncPaths = @{$DPaths{"Inc"}};
21078ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            push_U($SystemPaths{"include"}, @DefaultIncPaths);
21079ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
21080ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21081ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # users include paths
21082dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $IncPath = "/usr/include";
21083dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($SystemRoot) {
21084dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $IncPath = $SystemRoot.$IncPath;
21085dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
21086dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(-d $IncPath) {
21087570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@UsersIncPath, $IncPath);
21088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2109074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2109174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
2109274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
2109374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-libs", join("\n", @DefaultLibPaths));
2109474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-includes", join("\n", (@DefaultCppPaths, @DefaultGccPaths, @DefaultIncPaths)));
2109574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
21096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLIB_EXT($)
21099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
21101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_LibExt{$LIB_TYPE}{$Target}) {
21102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
21103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_LibExt{$LIB_TYPE}{"default"};
21105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAR_EXT($)
21108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
21110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_Archive{$Target}) {
21111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
21112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_Archive{"default"};
21114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpversion($)
21117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
21119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
21120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpversion"}{$Cmd}) {
21121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpversion"}{$Cmd};
21122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21123a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $V = `$Cmd -dumpversion 2>\"$TMP_DIR/null\"`;
21124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($V);
21125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpversion"}{$Cmd} = $V);
21126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpmachine($)
21129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
21131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
21132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpmachine"}{$Cmd}) {
21133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpmachine"}{$Cmd};
21134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21135a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Machine = `$Cmd -dumpmachine 2>\"$TMP_DIR/null\"`;
21136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($Machine);
21137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpmachine"}{$Cmd} = $Machine);
21138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21140570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub checkCmd($)
21141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
21143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
21144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Options = (
21145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "--version",
21146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "-help"
21147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
21148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Opt (@Options)
21149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21150a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my $Info = `$Cmd $Opt 2>\"$TMP_DIR/null\"`;
21151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Info) {
21152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
21153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
21156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2115862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub check_gcc($$)
21159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2116062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Cmd, $ReqVer) = @_;
2116162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $Cmd or not $ReqVer);
2116262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"check_gcc"}{$Cmd}{$ReqVer}) {
2116362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"check_gcc"}{$Cmd}{$ReqVer};
21164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2116562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $GccVer = get_dumpversion($Cmd))
2116662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2116762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $GccVer=~s/(-|_)[a-z_]+.*\Z//; # remove suffix (like "-haiku-100818")
2116862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(cmpVersions($GccVer, $ReqVer)>=0) {
2116962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = $Cmd);
2117062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2117162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2117262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = "");
21173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_depth($)
21176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_depth"}{$_[0]}) {
211789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_depth"}{$_[0]};
21179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_depth"}{$_[0]} = ($_[0]=~tr![\/\\]|\:\:!!));
21181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerGccHeaders()
21184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21185570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerGccHeaders"}); # this function should be called once
21186570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21187570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultGccPaths)
21188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21189570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($Path,"f");
21190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
21191570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $HPath (@Headers)
21192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($HPath);
21194570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultGccHeader{$FileName})
21195570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
21196570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $DefaultGccHeader{$FileName} = $HPath;
21197570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21200570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerGccHeaders"} = 1;
21201570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
21202570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21203570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerCppHeaders()
21204570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
21205570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerCppHeaders"}); # this function should be called once
21206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $CppDir (@DefaultCppPaths)
21208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($CppDir,"f");
21210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
21211570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (@Headers)
21212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21213570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($Path);
21214570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultCppHeader{$FileName})
21215570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
21216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DefaultCppHeader{$FileName} = $Path;
21217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerCppHeaders"} = 1;
21221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname($$$)
21224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
212259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $_[0]);
212269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]}) {
212279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]};
21228dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
212299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]} = parse_libname_I(@_));
212309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
212319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
212329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub parse_libname_I($$$)
212339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
212349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Name, $Type, $Target) = @_;
21235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Target eq "symbian") {
21237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_symbian($Name, $Type);
21238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Target eq "windows") {
21240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_windows($Name, $Type);
21241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21242fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21243fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    # unix
21244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT($Target);
21245a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Name=~/((((lib|).+?)([\-\_][\d\-\.\_]+.*?|))\.$Ext)(\.(.+)|)\Z/)
21246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libSDL-1.2.so.0.7.1
21247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # libwbxml2.so.0.0.18
21248a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko      # libopcodes-2.21.53-system.20110810.so
21249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2
21251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2.so
21256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2.so
21257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21261a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(defined $7
21262a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            and $7 ne "")
21263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0.7.1
21264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $7;
21265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
21267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # libc-2.5.so (=>2.5 version)
21268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MV = $5;
21269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MV=~s/\A[\-\_]+//g;
21270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MV;
21271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL
21275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SDL
21280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # wbxml
21281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_symbian($$)
21288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("symbian");
21291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/(((.+?)(\{.+\}|))\.$Ext)\Z/)
21292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libpthread{00010001}.dso
21293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}
21295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}.dso
21299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 00010001
21303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $V = $4;
21304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $V=~s/\{(.+)\}/$1/;
21305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $V;
21306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread
21309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # pthread
21313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_windows($$)
21320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("windows");
21323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/((.+?)\.$Ext)\Z/)
21324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # netapi32.dll
21325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32.dll
21331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # DLL version embedded
21335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # at binary-level
21336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
21337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi
21344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($2);
21345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub shortest_name($)
21351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
21353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove prefix
21354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\A(lib|open)//;
21355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove suffix
21356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/[\W\d_]+\Z//i;
21357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/([a-z]{2,})(lib)\Z/$1/i;
21358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
21359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createSymbolsList($$$$$)
21362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($DPath, $SaveTo, $LName, $LVersion, $ArchName) = @_;
21364ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    read_ABI_Dump(1, $DPath);
21366ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    prepareSymbols(1);
21367ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SymbolHeaderLib = ();
21369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Total = 0;
21370ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Get List
21372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
21373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not link_symbol($Symbol, 1, "-Deps"))
213751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
213781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Public", "Binary"))
21379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip other symbols
21380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
21383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HeaderName)
213841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
21388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DyLib)
213891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolHeaderLib{$HeaderName}{$DyLib}{$Symbol} = 1;
21393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Total+=1;
21394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Draw List
21396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SYMBOLS_LIST = "<h1>Public symbols in <span style='color:Blue;'>$LName</span> (<span style='color:Red;'>$LVersion</span>)";
21397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SYMBOLS_LIST .= " on <span style='color:Blue;'>".showArch($ArchName)."</span><br/>Total: $Total</h1><br/>";
21398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%SymbolHeaderLib))
21399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$SymbolHeaderLib{$HeaderName}}))
21401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %NS_Symbol = ();
21403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (keys(%{$SymbolHeaderLib{$HeaderName}{$DyLib}})) {
2140474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NS_Symbol{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
21405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NS_Symbol))
21407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
214081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SYMBOLS_LIST .= getTitle($HeaderName, $DyLib, $NameSpace);
21409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NS_Symbol{$NameSpace}});
21410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
21411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
21412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $SubReport = "";
21413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Symbol, 1);
21414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
2141562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
21416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Symbol=~/\A(_Z|\?)/)
21418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
214201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
214219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
21422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
21427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
21429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
21430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SYMBOLS_LIST .= $SubReport;
21436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SYMBOLS_LIST .= "<br/>\n";
21439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2144162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clear info
2144262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    (%TypeInfo, %SymbolInfo, %Library_Symbol, %DepSymbol_Library,
2144362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %DepLibrary_Symbol, %SymVer, %SkipTypes, %SkipSymbols,
2144462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %NestedNameSpaces, %ClassMethods, %AllocableClass, %ClassNames,
2144562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %CompleteSignature, %SkipNameSpaces, %Symbol_Library, %Library_Symbol) = ();
21446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($Content_Counter, $ContentID) = (0, 0);
2144762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # print report
214481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $CssStyles = readModule("Styles", "SymbolsList.css");
214491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $JScripts = readModule("Scripts", "Sections.js");
214501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = "<a name='Top'></a>".$SYMBOLS_LIST.$TOP_REF."<br/>\n";
21451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Title = "$LName: public symbols";
21452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Keywords = "$LName, API, symbols";
21453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Description = "List of symbols in $LName ($LVersion) on ".showArch($ArchName);
214541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."
21455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <body><div>\n$SYMBOLS_LIST</div>
2145641834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    <br/><br/>\n".getReportFooter()."
2145752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    </body></html>";
21458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile($SaveTo, $SYMBOLS_LIST);
21459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
214619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub add_target_libs($)
214629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
214639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach (@{$_[0]}) {
214649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TargetLibs{$_} = 1;
214659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
214669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
214679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
21468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_target_lib($)
21469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LName = $_[0];
21471a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(not $LName) {
21472a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return 0;
21473a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
21474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibraryName
21475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $LName!~/\Q$TargetLibraryName\E/) {
21476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%TargetLibs)
21479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{$LName}
21480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{parse_libname($LName, "name+ext", $OStarget)}) {
21481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
21484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21486850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub is_target_header($$)
21487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # --header, --headers-list
21488850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($H, $V) = @_;
21489850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(keys(%{$TargetHeaders{$V}}))
21490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21491850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($TargetHeaders{$V}{$H}) {
21492850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
21493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21495850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
21496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLibs($)
21499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows")
21502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dumpbin.exe will crash
21503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # without VS Environment
21504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        check_win32_env();
21505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
215061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    readSymbols($LibVersion);
21507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2150862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
21509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub dump_sorting($)
21512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21513989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my $Hash = $_[0];
21514989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if(not $Hash);
21515989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my @Keys = keys(%{$Hash});
21516989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if($#Keys<0);
21517989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Keys[0]=~/\A\d+\Z/)
21518989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # numbers
21519989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {int($a)<=>int($b)} @Keys];
21520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21521989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    else
21522989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # strings
21523989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {$a cmp $b} @Keys];
21524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printMsg($$)
21528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Type, $Msg) = @_;
21530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/\AINFO/) {
21531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg = $Type.": ".$Msg;
21532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/_C\Z/) {
21534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg .= "\n";
21535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet)
21537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet option
21538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($COMMON_LOG_PATH, $Msg);
21539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "ERROR") {
21543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print STDERR $Msg;
21544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print $Msg;
21547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitStatus($$)
21552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Code, $Msg) = @_;
21554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("ERROR", $Msg);
21555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{$Code});
21556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitReport()
21559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # the tool has run without any errors
21560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printReport();
21561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMPILE_ERRORS)
21562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # errors in headers may add false positives/negatives
21563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compile_Error"});
21564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
215651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $RESULT{"Binary"}{"Problems"})
215661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
215671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
215681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly and $RESULT{"Source"}{"Problems"})
215701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
215711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
215721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($RESULT{"Source"}{"Problems"}
215741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $RESULT{"Binary"}{"Problems"})
215751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
21576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
21577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
21579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compatible"});
21580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readRules($)
21584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Kind = $_[0];
21586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $RULES_PATH{$Kind}) {
21587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'".$RULES_PATH{$Kind}."\'");
21588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($RULES_PATH{$Kind});
21590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(my $Rule = parseTag(\$Content, "rule"))
21591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RId = parseTag(\$Rule, "id");
21593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Properties = ("Severity", "Change", "Effect", "Overcome", "Kind");
21594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prop (@Properties) {
21595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Value = parseTag(\$Rule, lc($Prop)))
21596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value=~s/\n[ ]*//;
21598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompatRules{$Kind}{$RId}{$Prop} = $Value;
21599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompatRules{$Kind}{$RId}{"Kind"}=~/\A(Symbols|Parameters)\Z/) {
21602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Symbols";
21603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Types";
21606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
216101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReportPath($)
216111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
216121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
216131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = "compat_reports/$TargetLibraryName/".$Descriptor{1}{"Version"}."_to_".$Descriptor{2}{"Version"};
216141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
216151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath)
216171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --bin-report-path
216181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $BinaryReportPath;
216191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
216211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
216221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
216231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
216251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
216261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/abi_compat_report.$ReportFormat";
216271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
216291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source")
216301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath)
216321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --src-report-path
216331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $SourceReportPath;
216341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
216361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
216371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
216381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
216401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
216411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/src_compat_report.$ReportFormat";
216421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
216441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
216451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
216471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
216481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
216491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
216511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
216521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/compat_report.$ReportFormat";
216531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
216551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
216561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
216571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub printStatMsg($)
216581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
216591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
216601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    printMsg("INFO", "total \"$Level\" compatibility problems: ".$RESULT{$Level}{"Problems"}.", warnings: ".$RESULT{$Level}{"Warnings"});
216611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
216621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
216631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub listAffected($)
216641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
216651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
216661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $List = "";
216671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach (keys(%{$TotalAffected{$Level}}))
216681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($StrictCompat and $TotalAffected{$Level}{$_} eq "Low")
216701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip "Low"-severity problems
216711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
216721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $List .= "$_\n";
216741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
216751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = get_dirname(getReportPath($Level));
216761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
216771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/abi_affected.txt", $List);
216781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
216791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source") {
216801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/src_affected.txt", $List);
216811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
216821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
216831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printReport()
21685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating compatibility report ...");
216871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    createReport();
216881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
216891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}
216911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $RESULT{"Source"}{"Problems"}) {
216921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (Binary: ".$RESULT{"Binary"}{"Affected"}."\%, Source: ".$RESULT{"Source"}{"Affected"}."\%)");
216931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
216951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
216961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
216981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
216991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
217001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
217011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
217021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
21703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
217061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}) {
217081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Binary"}{"Affected"}."\%)");
217091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
217111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
217121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
217141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
217151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
217161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
217171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
217201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Source"}{"Problems"}) {
217221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Source"}{"Affected"}."\%)");
217231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
217251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
217261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
217281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
217291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
217301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
217311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
217341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport or not $DoubleReport)
217360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # --binary or --source
217371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility report has been generated to stdout");
217381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
217401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
217411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility reports have been generated to stdout");
217421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
217451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
217461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
217470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
217481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Join"));
217491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($DoubleReport)
217511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
217521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed reports:\n  ".getReportPath("Binary")."\n  ".getReportPath("Source"));
217531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($BinaryOnly)
217551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --binary
217561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Binary"));
217571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
217581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($SourceOnly)
217591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --source
217601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Source"));
217611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub check_win32_env()
21766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $ENV{"DevEnvDir"}
21768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $ENV{"LIB"}) {
21769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't start without VS environment (vsvars32.bat)");
21770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
217735c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub diffSets($$)
217745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
217755c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my ($S1, $S2) = @_;
217765c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK1 = keys(%{$S1});
217775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK2 = keys(%{$S2});
217785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($#SK1!=$#SK2) {
217795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return 1;
217805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
217815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    foreach my $K1 (@SK1)
217825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
217835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not defined $S2->{$K1}) {
217845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            return 1;
217855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
217865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
217875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return 0;
217885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
217895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
217906bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenkosub defaultDumpPath($$)
217916bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko{
217926bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my ($N, $V) = @_;
217936bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    return "abi_dumps/".$N."/".$N."_".$V.".abi.".$AR_EXT; # gzipped by default
217946bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko}
217956bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko
21796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_ABI_Dump()
21797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -e $DumpAPI) {
21799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$DumpAPI\'");
21800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2180154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
21802ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($DumpAPI)) {
21803ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $DumpAPI);
21804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21805ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21806ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $DumpAPI));
21807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21810ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # set to default: N
21811ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $Descriptor{1}{"Version"} = "N";
21812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("inc|lib|bin|gcc"); # complete analysis
2181674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
218176bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my $DumpPath = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
218188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($OutputDumpPath)
218198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # user defined path
218208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $DumpPath = $OutputDumpPath;
2182174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
218228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Archive = ($DumpPath=~s/\Q.$AR_EXT\E\Z//g);
218238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
218248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $Archive and not $StdOut)
218258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # check archive utilities
218268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup eq "windows")
218278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using zip
218288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $ZipCmd = get_CmdPath("zip");
218298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $ZipCmd) {
218308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"zip\"");
218318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2183274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
218338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
218348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using tar and gzip
218358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
218368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $TarCmd) {
218378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\"");
218388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
218398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
218408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $GzipCmd) {
218418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\"");
218428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2184374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2184474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2184574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2184601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2184701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2184801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckHeadersOnly) {
2184901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readLibs(1);
2185001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2185101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($CheckHeadersOnly) {
2185201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            setLanguage(1, "C++");
2185301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21854ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2185554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
21856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2185701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2185801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2185901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Descriptor{1}{"Headers"}) {
2186001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readHeaders(1);
2186101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    cleanDump(1);
21864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{1}}))
21865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check if created dump is valid
21866ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
21867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckHeadersOnly) {
21869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty");
21870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
21872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection");
21873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeadersInfo = ();
21877fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $HPath (keys(%{$Registered_Headers{1}})) {
21878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HeadersInfo{$Registered_Headers{1}{$HPath}{"Identity"}} = $Registered_Headers{1}{$HPath}{"Pos"};
21879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21880570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ExtraDump)
21881570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # add unmangled names to the ABI dump
21882570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Names = ();
21883570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21884570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21885570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"}) {
21886570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@Names, $MnglName);
21887570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21888570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21889570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        translateSymbols(@Names, 1);
21890570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21891570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21892570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"})
21893570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
21894570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Unmangled = $tr_name{$MnglName})
21895570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
21896570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($MnglName ne $Unmangled) {
21897570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $SymbolInfo{1}{$InfoId}{"Unmangled"} = $Unmangled;
21898570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
21899570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
21900570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21901570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21902570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
21903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my %GccConstants = (); # built-in GCC constants
21905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (keys(%{$Constants{1}}))
21906fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
21907fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not defined $Constants{1}{$Name}{"Header"})
21908fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
21909fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $GccConstants{$Name} = $Constants{1}{$Name}{"Value"};
21910fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($Constants{1}{$Name});
21911fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
21912fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating library ABI dump ...");
2191501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %ABI = (
21916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "TypeInfo" => $TypeInfo{1},
21917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolInfo" => $SymbolInfo{1},
21918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Symbols" => $Library_Symbol{1},
2191962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "DepSymbols" => $DepLibrary_Symbol{1},
21920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolVersion" => $SymVer{1},
21921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryVersion" => $Descriptor{1}{"Version"},
21922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryName" => $TargetLibraryName,
21923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Language" => $COMMON_LANGUAGE{1},
21924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipTypes" => $SkipTypes{1},
21925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipSymbols" => $SkipSymbols{1},
21926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipNameSpaces" => $SkipNameSpaces{1},
21927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipHeaders" => $SkipHeadersList{1},
21928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Headers" => \%HeadersInfo,
21929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Constants" => $Constants{1},
21930fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        "GccConstants" => \%GccConstants,
21931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "NameSpaces" => $NestedNameSpaces{1},
21932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Target" => $OStarget,
21933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Arch" => getArch(1),
21934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "WordSize" => $WORD_SIZE{1},
21935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "GccVersion" => get_dumpversion($GCC_PATH),
21936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_DUMP_VERSION" => $ABI_DUMP_VERSION,
21937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_COMPLIANCE_CHECKER_VERSION" => $TOOL_VERSION
21938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
219395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(diffSets($TargetHeaders{1}, \%HeadersInfo)) {
2194001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"TargetHeaders"} = $TargetHeaders{1};
219415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
219425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML) {
2194301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"XML_ABI_DUMP_VERSION"} = $XML_ABI_DUMP_VERSION;
219445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
21945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
21946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
2194701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"Mode"} = "Extended";
21948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
219491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly)
219501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
2195101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"BinOnly"} = 1;
219521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2195374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
21954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # --extra-dump
2195574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ABI{"Extra"} = 1;
21956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"UndefinedSymbols"} = $UndefinedSymbols{1};
21957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"Needed"} = $Library_Needed{1};
2195874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
219595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
219605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $ABI_DUMP = "";
219615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML)
219625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
219635c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        loadModule("XmlDump");
2196401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = createXmlDump(\%ABI);
219655c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
219661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
219671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
2196801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = Dumper(\%ABI);
219691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
21970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
21971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --stdout option
219725c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print STDOUT $ABI_DUMP;
21973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI dump has been generated to stdout");
21974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
21975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # write to gzipped file
21978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($DDir, $DName) = separate_path($DumpPath);
21979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DPath = $TMP_DIR."/".$DName;
219805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $Archive) {
219815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $DPath = $DumpPath;
219825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
219835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DDir);
21985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21986850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(DUMP, ">", $DPath) || die ("can't open file \'$DPath\': $!\n");
219875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print DUMP $ABI_DUMP;
21988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(DUMP);
21989850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -s $DPath) {
21991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't create ABI dump because something is going wrong with the Data::Dumper module");
21992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2199307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Archive) {
2199407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $DumpPath = createArchive($DPath, $DDir);
219955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
2199607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
21997ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($OutputDumpPath) {
219989e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            printMsg("INFO", "dump path: $OutputDumpPath");
21999ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
22000ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        else {
220019e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko            printMsg("INFO", "dump path: $DumpPath");
220025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
220039e05beee1bb110a2b6e13a36119c9893ed0c5414Andrey Ponomarenko        # printMsg("INFO", "you can transfer this dump everywhere and use instead of the ".$Descriptor{1}{"Version"}." version descriptor");
22004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub quickEmptyReports()
22008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # Quick "empty" reports
22009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # 4 times faster than merging equal dumps
22010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # NOTE: the dump contains the "LibraryVersion" attribute
22011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # if you change the version, then your dump will be different
22012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME: use -v1 and v2 options for comparing dumps
22013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # and don't change version in the XML descriptor (and dumps)
22014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME 2: separate meta info from the dumps in ACC 2.0
22015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-s $Descriptor{1}{"Path"} == -s $Descriptor{2}{"Path"})
22016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath1 = unpackDump($Descriptor{1}{"Path"});
22018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath2 = unpackDump($Descriptor{2}{"Path"});
22019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($FilePath1 and $FilePath2)
22020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2202101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Line = readLineNum($FilePath1, 0);
2202201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($Line=~/xml/)
2202301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # XML format
2202401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                # is not supported yet
2202501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return;
2202601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2202701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
22028850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            local $/ = undef;
22029850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22030850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP1, $FilePath1);
22031850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content1 = <DUMP1>;
22032850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP1);
22033850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22034850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP2, $FilePath2);
22035850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content2 = <DUMP2>;
22036850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP2);
22037850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22038850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Content1 eq $Content2)
22039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
22040850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
22041850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content2;
22042850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # read a number of headers, libs, symbols and types
22044850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $ABIdump = eval($Content1);
22045850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22046850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
22047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content1;
22048850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump) {
220509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
22051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"TypeInfo"})
220531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
22054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"TypeInfo"} = $ABIdump->{"TypeDescr"};
22055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"SymbolInfo"})
220571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
22058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"SymbolInfo"} = $ABIdump->{"FuncDescr"};
22059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22060fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                read_Source_DumpInfo($ABIdump, 1);
22061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Libs_DumpInfo($ABIdump, 1);
22062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 1);
22063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 2);
220641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
220651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Binary"}} = %{$ABIdump->{"TypeInfo"}};
220661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Source"}} = %{$ABIdump->{"TypeInfo"}};
220671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
220681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Binary"}} = %{$ABIdump->{"SymbolInfo"}};
220691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Source"}} = %{$ABIdump->{"SymbolInfo"}};
220701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
22071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{1}{"Version"} = $TargetVersion{1}?$TargetVersion{1}:$ABIdump->{"LibraryVersion"};
22072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{2}{"Version"} = $TargetVersion{2}?$TargetVersion{2}:$ABIdump->{"LibraryVersion"};
22073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitReport();
22074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub initLogging($)
22080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create log directory
22083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LOG_DIR, $LOG_FILE) = ("logs/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"}, "log.txt");
22084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OutputLogPath{$LibVersion})
22085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined by -log-path option
22086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($LOG_DIR, $LOG_FILE) = separate_path($OutputLogPath{$LibVersion});
22087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($LOG_DIR);
22090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $LOG_PATH{$LibVersion} = get_abs_path($LOG_DIR)."/".$LOG_FILE;
22092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
22093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug directory
22094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $DEBUG_PATH{$LibVersion} = "debug/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"};
2209574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2209674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $ExtraInfo)
2209774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # enable --extra-info
2209874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $ExtraInfo = $DEBUG_PATH{$LibVersion}."/extra-info";
2209974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
22100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2210135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    resetLogging($LibVersion);
22102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeLog($$)
22105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Msg) = @_;
22107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($LOG_PATH{$LibVersion}, $Msg);
22109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub resetLogging($)
22113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode!~/a|n/)
22116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # remove old log
22117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($LOG_PATH{$LibVersion});
2211835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Debug) {
2211935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            rmtree($DEBUG_PATH{$LibVersion});
2212035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
22121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printErrorLog($)
22125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "see log for details:\n  ".$LOG_PATH{$LibVersion}."\n");
22129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isDump($)
22133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22134b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.tar\.gz(\.\w+|)|\.zip|\.xml|)\Z/)
22135b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    { # NOTE: name.abi.tar.gz.amd64 (dh & cdbs)
221369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $1;
221379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
221389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return 0;
221399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
221409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
221419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub isDump_U($)
221429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
22143b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.xml|)\Z/) {
22144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $1;
22145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
22147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
221491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareInit()
22150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # read input XML descriptors or ABI dumps
22152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Path"}) {
221530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-old option is not specified");
22154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22155ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{1}{"Path"}) {
22156ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{1}{"Path"}."\'");
22157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22158ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Path"}) {
221600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-new option is not specified");
22161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22162ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{2}{"Path"}) {
22163ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{2}{"Path"}."\'");
22164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22165ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("bin"); # to extract dumps
22167ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})
22168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{2}{"Path"}))
22169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # optimization: equal ABI dumps
22170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        quickEmptyReports();
22171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22172ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "preparation, please wait ...");
22174ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22175ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})) {
22176ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $Descriptor{1}{"Path"});
22177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22178ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
22179ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $Descriptor{1}{"Path"}));
22180ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22181ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22182ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{2}{"Path"})) {
22183ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(2, $Descriptor{2}{"Path"});
22184ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22185ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
22186ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(2, createDescriptor(2, $Descriptor{2}{"Path"}));
22187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22188fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22189fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
22190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
22191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
2219215bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        print STDERR "WARNING: version number #1 is not set (use --v1=NUM option)\n";
22193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{2}{"Version"})
22196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: Y
22197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{2}{"Version"} = "Y";
2219815bfdc281d18ec26a6a056ed45d641a885716165Andrey Ponomarenko        print STDERR "WARNING: version number #2 is not set (use --v2=NUM option)\n";
22199fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
222012c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    if(not $UsedDump{1}{"V"}) {
222022c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        initLogging(1);
222032c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
222042c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko
222052c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    if(not $UsedDump{2}{"V"}) {
222062c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko        initLogging(2);
222072c530f7b889fa43ba20e972c3ef5b7ccf0d5d2a8Andrey Ponomarenko    }
22208ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22209ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # check input data
22210ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}) {
22211ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d1");
22212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22213ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"}) {
22214ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d2");
22215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22216ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22217ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $CheckHeadersOnly)
22218bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22219ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{1}{"Libs"}) {
22220ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d1");
22221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22222ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{2}{"Libs"}) {
22223ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d2");
22224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22226ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UseDumps)
22228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --use-dumps
22229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # parallel processing
222306bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath1 = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
222316bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath2 = defaultDumpPath($TargetLibraryName, $Descriptor{2}{"Version"});
2223274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2223374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath1);
2223474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath2);
2223574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
22236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $pid = fork();
22237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($pid)
22238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # dump on two CPU cores
22239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{1}{"Path"}, "-l", $TargetLibraryName);
22240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{1}) {
22241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{1});
22242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{1}) {
22244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{1});
22245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22249dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22250dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22252dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22253dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22254dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22255dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22256dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{1}) {
22265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{1});
22266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22270850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2227362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2227462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2227562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2227601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2227701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2227801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22279f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22280f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22281f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22282850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22283850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22284850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2228562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22286850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2228874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath1) {
22289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
22293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # child
22294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{2}{"Path"}, "-l", $TargetLibraryName);
22295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{2}) {
22296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{2});
22297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{2}) {
22299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{2});
22300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22304dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22305dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22307dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22308dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22309dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22310dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22311dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{2}) {
22320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{2});
22321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22322850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22326850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22327850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2232862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2232962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2233101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2233201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2233301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22334f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22335f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22336f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22337850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22338850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22339850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2234062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22341850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2234374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath2) {
22344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(0);
22348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        waitpid($pid, 0);
2235114b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko
22352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @CMP_PARAMS = ("-l", $TargetLibraryName);
2235374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d1", $DumpPath1);
2235474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d2", $DumpPath2);
2235514b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        if($TargetTitle ne $TargetLibraryName) {
2235614b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-title", $TargetTitle);
22357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShowRetVal) {
22359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-show-retval");
22360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc) {
22362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-cross-gcc", $CrossGcc);
22363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2236435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-logging-mode", "a");
2236535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Quiet) {
22366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-quiet");
22367dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
22368dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($ReportFormat and $ReportFormat ne "html")
22369dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # HTML is default format
22370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-format", $ReportFormat);
22371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
223721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath) {
223731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-path", $OutputReportPath);
223741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath) {
223761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-bin-report-path", $BinaryReportPath);
223771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath) {
223791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-src-report-path", $SourceReportPath);
223801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($LoggingPath) {
223821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-log-path", $LoggingPath);
223831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22384f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckHeadersOnly) {
22385f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-headers-only");
22386f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22387f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($BinaryOnly) {
22388f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-binary");
22389f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22390f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($SourceOnly) {
22391f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-source");
22392f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2239362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug)
2239462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2239562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-debug");
2239662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running perl $0 @CMP_PARAMS");
22397850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
22398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system("perl", $0, @CMP_PARAMS);
22399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($?>>8);
22400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"}
22402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Dump"})
22403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # need GCC toolchain to analyze
22404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # header files and libraries
22405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("inc|lib|gcc");
22406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
22408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(1);
22411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(1, "C++");
22414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22415ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2241654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
22417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Dump"})
22419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(2);
22422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(2, "C++");
22425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22426ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(2);
2242754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{2} = detectWordSize(2);
22428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($WORD_SIZE{1} ne $WORD_SIZE{2})
22430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # try to synch different WORD sizes
2243262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.1"))
22433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{1} = $WORD_SIZE{2};
22435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{2}." bytes");
22436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2243762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(not checkDump(2, "2.1"))
22438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{2} = $WORD_SIZE{1};
22440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{1}." bytes");
22441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $WORD_SIZE{1}
22444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $WORD_SIZE{2})
22445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2244662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{1} = "4";
2244762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{2} = "4";
22448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Dump"})
22450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(1);
22452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{2}{"Dump"})
22454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(2);
22456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath and not keys(%{$Symbol_Library{1}})) {
22458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("WARNING", "the application ".get_filename($AppPath)." has no symbols imported from the $SLIB_TYPE libraries");
22459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22460ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # process input data
22461ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{1}{"Headers"}
22462ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{1}{"Dump"}) {
22463ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(1);
22464ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22465ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{2}{"Headers"}
22466ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{2}{"Dump"}) {
22467ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(2);
22468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22469850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22470850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
22471850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %SystemHeaders = ();
22472850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %mangled_name_gcc = ();
22473850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
224741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(1);
224751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(2);
224761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
22477850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
224781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %SymbolInfo = ();
224791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Virtual Tables
224811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(1);
224821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(2);
224831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
2248462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "1.22")
2248562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and checkDump(2, "1.22"))
224861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # support for old ABI dumps
224871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $ClassName (keys(%{$VirtualTable{2}}))
224881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
224891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($ClassName=~/</)
224901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # templates
224911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not defined $VirtualTable{1}{$ClassName})
224921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # synchronize
224931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    delete($VirtualTable{2}{$ClassName});
224941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
224951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
224961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
224971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
224981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(1);
225001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(2);
225011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
225021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(1);
225031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(2);
225041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
225051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Other
225061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(1);
225071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(2);
225081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
225091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    detectChangedTypedefs();
225101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
225111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
225121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareAPIs($)
225131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
225141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
22515ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
225161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    readRules($Level);
22517f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    loadModule("CallConv");
22518ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
225191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
225201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing ABIs ...");
225211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
225221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
225231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing APIs ...");
225241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22525ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
225261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
225271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
22528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # added/removed in headers
225291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded_H($Level);
225301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved_H($Level);
22531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
225331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
225341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded($Level);
225351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved($Level);
225361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22537ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22538ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    mergeSymbols($Level);
22539ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(keys(%{$CheckedSymbols{$Level}})) {
22540ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        mergeConstants($Level);
225411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22542f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
22543f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Cache{"mergeTypes"} = (); # free memory
22544f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
225451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
225461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
225471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in headers
225481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeHeaders($Level);
225491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
225501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
225511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
225521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeLibs($Level);
22553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
225569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSysOpts()
22557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Opts = (
22559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "OStarget"=>$OStarget,
22560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Debug"=>$Debug,
22561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Quiet"=>$Quiet,
22562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "LogMode"=>$LogMode,
22563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CheckHeadersOnly"=>$CheckHeadersOnly,
22564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "SystemRoot"=>$SystemRoot,
22566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "GCC_PATH"=>$GCC_PATH,
22567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetSysInfo"=>$TargetSysInfo,
22568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossPrefix"=>$CrossPrefix,
22569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetLibraryName"=>$TargetLibraryName,
22570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossGcc"=>$CrossGcc,
22571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "UseStaticLibs"=>$UseStaticLibs,
225729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NoStdInc"=>$NoStdInc,
225739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
225749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BinaryOnly" => $BinaryOnly,
225759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SourceOnly" => $SourceOnly
22576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
22577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Opts;
22578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2258074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_CodeError($)
22581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %CODE_ERROR = reverse(%ERROR_CODE);
22583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CODE_ERROR{$_[0]};
22584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub scenario()
22587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # enable quiet mode
22590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Quiet = 1;
225911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 1;
22592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22593dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $LogMode)
22594dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # default
22595dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $LogMode = "w";
22596dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
22597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UserLang)
22598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C++
22599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UserLang = uc($UserLang);
22600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{1}=$UserLang;
22601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{2}=$UserLang;
22602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LoggingPath)
22604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{1} = $LoggingPath;
22606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{2} = $LoggingPath;
22607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Quiet) {
22608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $COMMON_LOG_PATH = $LoggingPath;
22609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226111fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
226121fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalSymbols) {
226131fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $SkipInternalSymbols=~s/\*/.*/g;
226141fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
226151fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
226161fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    if($SkipInternalTypes) {
226171fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $SkipInternalTypes=~s/\*/.*/g;
226181fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko    }
226191fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko
22620e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if($Quick) {
22621e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        $ADD_TMPL_INSTANCES = 0;
22622e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
226235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($OutputDumpPath)
226245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
2262574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not isDump($OutputDumpPath)) {
226265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "the dump path should be a path to *.abi.$AR_EXT or *.abi file");
226275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
226285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
226291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $SourceOnly)
226301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # both --binary and --source
226311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # is the default mode
226325e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        if(not $CmpSystems)
226335e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        {
226345e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $BinaryOnly = 0;
226355e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $SourceOnly = 0;
226365e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        }
226375e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
226381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 1;
226391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
226405e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
226411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
226421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
226431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $DoubleReport = 0;
226441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JoinReport = 1;
226451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
226461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
226471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly or $SourceOnly)
226481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary or --source
226491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 0;
226501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
226511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
226521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($UseXML)
226531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --xml option
226541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = "xml";
226555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "xml";
226561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat)
22658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate
226591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = lc($ReportFormat);
226601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat!~/\A(xml|html|htm)\Z/) {
226615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown report format \'$ReportFormat\'");
22662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
226631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat eq "htm")
226641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # HTM == HTML
226651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ReportFormat = "html";
226661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
226671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($ReportFormat eq "xml")
226681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-format=XML equal to --xml
226691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $UseXML = 1;
226701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # default: HTML
22674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ReportFormat = "html";
22675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226765c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($DumpFormat)
226775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
226785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = lc($DumpFormat);
226795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat!~/\A(xml|perl)\Z/) {
226805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown ABI dump format \'$DumpFormat\'");
226815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
226825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat eq "xml")
226835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # --dump-format=XML equal to --xml
226845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $UseXML = 1;
226855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
226865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
226875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
2268801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # default: Perl Data::Dumper
226895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "perl";
226905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet and $LogMode!~/a|n/)
22692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet log
22693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $COMMON_LOG_PATH) {
22694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($COMMON_LOG_PATH);
22695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226974b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($ExtraInfo) {
22698570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CheckUndefined = 1;
22699570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool and $UseDumps)
22701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test && --use-dumps == --test-dump
22702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestDump = 1;
22703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
227048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerant)
227058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # enable all
227068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Tolerance = 1234;
227078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
22708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Help)
22709570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        HELP_MESSAGE();
22711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22713ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if($InfoMsg)
22714ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
22715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        INFO_MESSAGE();
22716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22718570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ShowVersion)
22719570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2272052b2e35f3dfda9369631beeb5d5480df65c47950Andrey 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.");
22721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22723570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($DumpVersion)
22724570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", $TOOL_VERSION);
22726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck) {
22729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CheckHeadersOnly = 1;
22730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot_Opt)
22732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user defined root
22733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $SystemRoot_Opt) {
22734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$SystemRoot\'");
22735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot = $SystemRoot_Opt;
22737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot=~s/[\/]+\Z//g;
22738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
22739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SystemRoot = get_abs_path($SystemRoot);
22740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Data::Dumper::Sortkeys = 1;
22743989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2274462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($SortDump)
2274562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2274662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Useperl = 1;
2274762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Sortkeys = \&dump_sorting;
2274862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
22749989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
22750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibsPath)
22751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetLibsPath) {
22753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetLibsPath\'");
22754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Lib (split(/\s*\n\s*/, readFile($TargetLibsPath))) {
22756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetLibs{$Lib} = 1;
22757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeadersPath)
22760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --headers-list
22761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetHeadersPath) {
22762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetHeadersPath\'");
22763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, readFile($TargetHeadersPath)))
22765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
227661fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $TargetHeaders{1}{get_filename($Header)} = 1;
227671fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko            $TargetHeaders{2}{get_filename($Header)} = 1;
22768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeader)
22771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --header
227721fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $TargetHeaders{1}{get_filename($TargetHeader)} = 1;
227731fbbce64f39fad73a23b246b94e958108cb0ae36Andrey Ponomarenko        $TargetHeaders{2}{get_filename($TargetHeader)} = 1;
22774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool
22776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $TestDump)
22777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test, --test-dump
22778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to compile libs
22779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("RegTests");
22780f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        testTool($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, $DumpFormat,
22781ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $LIB_EXT, $GCC_PATH, $SortDump, $CheckHeadersOnly);
22782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpSystem)
22785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-system
2278652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2278752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not $TargetSysInfo) {
2278852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Error", "-sysinfo option should be specified to dump system ABI");
2278952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2279052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2279152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -d $TargetSysInfo) {
2279252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$TargetSysInfo\'");
2279352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2279452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
22795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
227969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($DumpSystem=~/\.(xml|desc)\Z/)
22797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # system XML descriptor
22798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -f $DumpSystem) {
22799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$DumpSystem\'");
22800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22801e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
22802e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $SDesc = readFile($DumpSystem);
22803e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            if(my $RelDir = $RelativeDirectory{1}) {
22804e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko                $SDesc =~ s/{RELPATH}/$RelDir/g;
22805e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            }
22806e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
22807e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $Ret = readSystemDescriptor($SDesc);
228089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            foreach (@{$Ret->{"Tools"}})
228099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
22810570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"bin"}, $_);
22811570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $TargetTools{$_} = 1;
22812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Ret->{"CrossPrefix"}) {
22814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CrossPrefix = $Ret->{"CrossPrefix"};
22815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($SystemRoot_Opt)
22818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -sysroot "/" option
22819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # default target: /usr/lib, /usr/include
22820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # search libs: /usr/lib and /lib
22821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/lib") {
22822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/lib'");
22823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/lib") {
22825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/lib'");
22826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/include") {
22828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/include'");
22829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readSystemDescriptor("
22831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <name>
22832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DumpSystem
22833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </name>
22834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
22835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/include
22836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
22837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
22838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/lib
22839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>
22840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <search_libs>
22841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/lib
22842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </search_libs>");
22843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "-sysroot <dirpath> option should be specified, usually it's \"/\"");
22846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to check symbols
22848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
22849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # to run dumpbin.exe
22850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and undname.exe
22851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            check_win32_env();
22852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
228539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        dumpSystem(getSysOpts());
22854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CmpSystems)
22857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --cmp-systems
22858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin"); # to extract dumps
22859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
228609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        cmpSystems($Descriptor{1}{"Path"}, $Descriptor{2}{"Path"}, getSysOpts());
22861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryName) {
22864570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Error", "library name is not selected (-l option)");
22865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate library name
22868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryName=~/[\*\/\\]/) {
22869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "\"\\\", \"\/\" and \"*\" symbols are not allowed in the library name");
22870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2287214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko    if(not $TargetTitle) {
2287314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $TargetTitle = $TargetLibraryName;
22874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22875ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolsListPath)
22877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SymbolsListPath) {
22879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SymbolsListPath\'");
22880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SymbolsListPath))) {
22882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList{$Interface} = 1;
22883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2288552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($TypesListPath)
2288652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
2288752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -f $TypesListPath) {
2288852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TypesListPath\'");
2288952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2289052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($TypesListPath))) {
2289152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $TypesList{$Type} = 1;
2289252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2289352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
22894fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($SkipSymbolsListPath)
22895fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
22896fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not -f $SkipSymbolsListPath) {
22897fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipSymbolsListPath\'");
22898fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22899a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SkipSymbolsListPath)))
22900a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        {
22901a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{1}{$Interface} = 1;
22902a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{2}{$Interface} = 1;
22903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
2290599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    if($SkipTypesListPath)
2290699640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    {
2290799640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        if(not -f $SkipTypesListPath) {
2290899640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipTypesListPath\'");
2290999640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2291099640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($SkipTypesListPath)))
2291199640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        {
2291299640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            $SkipTypes{1}{$Type} = 1;
2291399640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko            $SkipTypes{2}{$Type} = 1;
2291499640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko        }
2291599640d301c76bbdcf86803858ed9190d3f249133Andrey Ponomarenko    }
22916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipHeadersPath)
22917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SkipHeadersPath) {
22919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipHeadersPath\'");
22920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, readFile($SkipHeadersPath)))
229221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register for both versions
229231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{1}{$Path} = 1;
229241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{2}{$Path} = 1;
22925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($CPath, $Type) = classifyPath($Path);
22926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{1}{$Type}{$CPath} = 1;
22927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{2}{$Type}{$CPath} = 1;
22928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ParamNamesPath)
22931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $ParamNamesPath) {
22933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$ParamNamesPath\'");
22934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Line (split(/\n/, readFile($ParamNamesPath)))
22936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~s/\A(\w+)\;//)
22938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
22939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Interface = $1;
2294062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Line=~/;(\d+);/)
2294162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    while($Line=~s/(\d+);(\w+)//) {
22943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$1}=$2;
22944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2294662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
2294762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Num = 0;
22949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Name (split(/;/, $Line)) {
22950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$Num++}=$Name;
22951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath)
22957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $AppPath) {
22959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$AppPath\'");
22960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22961ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22962ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        detect_default_paths("bin|gcc");
229631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $Interface (readSymbols_App($AppPath)) {
22964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList_App{$Interface} = 1;
22965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpAPI)
22968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-abi
22969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # make an API dump
22970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        create_ABI_Dump();
22971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($COMPILE_ERRORS);
22972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # default: compare APIs
22974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d1 <path>
22975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d2 <path>
229761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    compareInit();
229771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
229781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
229791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
229801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
229811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
229821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly) {
229831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
229841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
229851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly) {
229861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
229871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitReport();
22989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoscenario();
22992