abi-compliance-checker.pl revision a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0
1ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#!/usr/bin/perl
2ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
3a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko# ABI Compliance Checker (ABICC) 1.99.11
41bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# A tool for checking backward compatibility of a C/C++ library API
5ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
6850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2009-2011 Institute for System Programming, RAS
7850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies)
88bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko# Copyright (C) 2011-2012 ROSA Laboratory
98bfdcd89d96039c2f655682c39386097759501ceAndrey Ponomarenko# Copyright (C) 2012-2015 Andrey Ponomarenko's ABI Laboratory
10ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
11ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Written by Andrey Ponomarenko
12ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
13ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# PLATFORMS
14ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# =========
15ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Linux, FreeBSD, Mac OS X, Haiku, MS Windows, Symbian
16ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
17ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# REQUIREMENTS
18ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# ============
19ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Linux
20c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - G++ (3.0-4.7, 4.8.3, 4.9 or newer)
21ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - GNU Binutils (readelf, c++filt, objdump)
22850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Perl 5 (5.8 or newer)
23f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
24ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
25ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  Mac OS X
26570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko#    - Xcode (g++, c++filt, otool, nm)
27f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
28ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
29ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#  MS Windows
30c522134dcd0c1d963ec558179038e5869ae34298Andrey Ponomarenko#    - MinGW (3.0-4.7, 4.8.3, 4.9 or newer)
31ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - MS Visual C++ (dumpbin, undname, cl)
32850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko#    - Active Perl 5 (5.8 or newer)
33ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Sigcheck v1.71 or newer
34ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Info-ZIP 3.0 (zip, unzip)
35f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko#    - Ctags (5.8 or newer)
3674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#    - Add tool locations to the PATH environment variable
37ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#    - Run vsvars32.bat (C:\Microsoft Visual Studio 9.0\Common7\Tools\)
38ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
39ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko# COMPATIBILITY
40ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko# =============
4152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko#  ABI Dumper >= 0.99.9
42ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko#
43ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko#
44ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is free software: you can redistribute it and/or modify
45ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# it under the terms of the GNU General Public License or the GNU Lesser
46ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# General Public License as published by the Free Software Foundation.
47ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
48ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This program is distributed in the hope that it will be useful,
49ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# but WITHOUT ANY WARRANTY; without even the implied warranty of
50ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
51ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# GNU General Public License for more details.
52ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
53ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# You should have received a copy of the GNU General Public License
54ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# and the GNU Lesser General Public License along with this program.
55ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# If not, see <http://www.gnu.org/licenses/>.
56ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
57ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Getopt::Long;
58ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetopt::Long::Configure ("posix_default", "no_ignore_case");
59ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Path qw(mkpath rmtree);
60ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Temp qw(tempdir);
61ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse File::Copy qw(copy move);
6274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkouse Cwd qw(abs_path cwd realpath);
63177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkouse Storable qw(dclone);
64ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkouse Data::Dumper;
652fba63087b6e973c04b6d235fe10363657985263Andrey Ponomarenkouse Config;
66ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenkomy $TOOL_VERSION = "1.99.11";
68177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ABI_DUMP_VERSION = "3.2";
69d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenkomy $XML_REPORT_VERSION = "1.2";
70f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy $XML_ABI_DUMP_VERSION = "1.2";
71ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OSgroup = get_OSgroup();
72ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ORIG_DIR = cwd();
73ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TMP_DIR = tempdir(CLEANUP=>1);
746fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenkomy $LOCALE = "C.UTF-8";
75ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
76ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Internal modules
77ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MODULES_DIR = get_Modules();
78ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkopush(@INC, get_dirname($MODULES_DIR));
79ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Rules DB
80ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RULES_PATH = (
81ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Binary" => $MODULES_DIR."/RulesBin.xml",
82ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Source" => $MODULES_DIR."/RulesSrc.xml");
83ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8414b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenkomy ($Help, $ShowVersion, %Descriptor, $TargetLibraryName,
85ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TestTool, $DumpAPI, $SymbolsListPath, $CheckHeadersOnly_Opt, $UseDumps,
86ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko$AppPath, $StrictCompat, $DumpVersion, $ParamNamesPath,
8714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko%RelativeDirectory, $TargetTitle, $TestDump, $LoggingPath,
886ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko%TargetVersion, $InfoMsg, $CrossGcc, %OutputLogPath,
89ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$OutputReportPath, $OutputDumpPath, $ShowRetVal, $SystemRoot_Opt, $DumpSystem,
90ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$CmpSystems, $TargetLibsPath, $Debug, $CrossPrefix, $UseStaticLibs, $NoStdInc,
91ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TargetComponent_Opt, $TargetSysInfo, $TargetHeader, $ExtendedCheck, $Quiet,
9207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko$SkipHeadersPath, $CppCompat, $LogMode, $StdOut, $ListAffected, $ReportFormat,
931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko$UserLang, $TargetHeadersPath, $BinaryOnly, $SourceOnly, $BinaryReportPath,
9452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko$SourceReportPath, $UseXML, $SortDump, $DumpFormat,
95177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko$ExtraInfo, $ExtraDump, $Force, $Tolerance, $Tolerant, $SkipSymbolsListPath,
9654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko$CheckInfo, $Quick, $AffectLimit, $AllAffected, $CppIncompat, $SkipInternal,
9752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko$TargetArch, $GccOptions, $TypesListPath);
98ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
99ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CmdName = get_filename($0);
100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_LibExt = (
101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic" => {
1029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"so",
103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "macos"=>"dylib",
104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"dll",
1059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"dso",
1069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"so"
107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static" => {
1099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"a",
110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"lib",
1119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"lib",
1129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"a"
113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_Archive = (
117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"zip",
118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"tar.gz"
119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ERROR_CODE = (
122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Compatible verdict
123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compatible"=>0,
124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Success"=>0,
125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible verdict
126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Incompatible"=>1,
127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Undifferentiated error code
128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Error"=>2,
129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # System command is not found
130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Not_Found"=>3,
131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot access input files
132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Access_Error"=>4,
133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot compile header files
134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Cannot_Compile"=>5,
135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Header compiled with errors
136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compile_Error"=>6,
137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Invalid input ABI dump
138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Invalid_Dump"=>7,
139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible version of ABI dump
140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Dump_Version"=>8,
141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot find a module
142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Module_Error"=>9,
143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty intersection between
144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # headers and shared objects
145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Intersection"=>10,
146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty set of symbols in headers
147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Set"=>11
148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkomy $HomePage = "http://lvc.github.io/abi-compliance-checker/";
151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
152b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenkomy $ShortUsage = "ABI Compliance Checker (ABICC) $TOOL_VERSION
1531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey PonomarenkoA tool for checking backward compatibility of a C/C++ library API
15452b2e35f3dfda9369631beeb5d5480df65c47950Andrey PonomarenkoCopyright (C) 2015 Andrey Ponomarenko's ABI Laboratory
155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoLicense: GNU LGPL or GNU GPL
156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUsage: $CmdName [options]
158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey PonomarenkoExample: $CmdName -lib NAME -old OLD.xml -new NEW.xml
159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOLD.xml and NEW.xml are XML-descriptors:
161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/headers/
168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/libraries/
172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMore info: $CmdName --help\n";
175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkoif($#ARGV==-1)
177570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $ShortUsage);
179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit(0);
180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetOptions("h|help!" => \$Help,
183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "i|info!" => \$InfoMsg,
184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v|version!" => \$ShowVersion,
185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dumpversion!" => \$DumpVersion,
186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# general options
187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l|lib|library=s" => \$TargetLibraryName,
188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d1|old|o=s" => \$Descriptor{1}{"Path"},
189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d2|new|n=s" => \$Descriptor{2}{"Path"},
190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump|dump-abi|dump_abi=s" => \$DumpAPI,
191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# extra options
192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "app|application=s" => \$AppPath,
193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "static-libs!" => \$UseStaticLibs,
194d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-path|cross-gcc=s" => \$CrossGcc,
195d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-prefix|cross-prefix=s" => \$CrossPrefix,
196d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko  "gcc-options=s" => \$GccOptions,
197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysroot=s" => \$SystemRoot_Opt,
198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v1|version1|vnum=s" => \$TargetVersion{1},
199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v2|version2=s" => \$TargetVersion{2},
200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "s|strict!" => \$StrictCompat,
201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "symbols-list=s" => \$SymbolsListPath,
20252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko  "types-list=s" => \$TypesListPath,
203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "skip-symbols=s" => \$SkipSymbolsListPath,
204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "headers-list=s" => \$TargetHeadersPath,
205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "skip-headers=s" => \$SkipHeadersPath,
206fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "header=s" => \$TargetHeader,
207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "headers-only|headers_only!" => \$CheckHeadersOnly_Opt,
208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "show-retval!" => \$ShowRetVal,
209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "use-dumps!" => \$UseDumps,
210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "nostdinc!" => \$NoStdInc,
211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-system=s" => \$DumpSystem,
212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysinfo=s" => \$TargetSysInfo,
213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "cmp-systems!" => \$CmpSystems,
214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "libs-list=s" => \$TargetLibsPath,
215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "ext|extended!" => \$ExtendedCheck,
216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "q|quiet!" => \$Quiet,
217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "stdout!" => \$StdOut,
218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-format=s" => \$ReportFormat,
2195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko  "dump-format=s" => \$DumpFormat,
2201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "xml!" => \$UseXML,
221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "lang=s" => \$UserLang,
22254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  "arch=s" => \$TargetArch,
2231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "binary|bin|abi!" => \$BinaryOnly,
2241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "source|src|api!" => \$SourceOnly,
2252489ef88760861175102e4508089608391beead3Andrey Ponomarenko  "limit-affected|affected-limit=s" => \$AffectLimit,
226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# other options
227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test!" => \$TestTool,
228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test-dump!" => \$TestDump,
229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "debug!" => \$Debug,
23007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "cpp-compatible!" => \$CppCompat,
2312b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  "cpp-incompatible!" => \$CppIncompat,
232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "p|params=s" => \$ParamNamesPath,
233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath1|relpath=s" => \$RelativeDirectory{1},
234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath2=s" => \$RelativeDirectory{2},
235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-path=s" => \$OutputDumpPath,
23662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "sort!" => \$SortDump,
237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-path=s" => \$OutputReportPath,
2381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "bin-report-path=s" => \$BinaryReportPath,
2391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "src-report-path=s" => \$SourceReportPath,
240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log-path=s" => \$LoggingPath,
241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log1-path=s" => \$OutputLogPath{1},
242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log2-path=s" => \$OutputLogPath{2},
243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "logging-mode=s" => \$LogMode,
244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "list-affected!" => \$ListAffected,
24514b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  "title|l-full|lib-full=s" => \$TargetTitle,
2461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "component=s" => \$TargetComponent_Opt,
247570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-info=s" => \$ExtraInfo,
248570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-dump!" => \$ExtraDump,
2498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "force!" => \$Force,
2508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "tolerance=s" => \$Tolerance,
251177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "tolerant!" => \$Tolerant,
252e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "check!" => \$CheckInfo,
253f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko  "quick!" => \$Quick,
254d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko  "all-affected!" => \$AllAffected,
255d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko  "skip-internal=s" => \$SkipInternal
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
462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The list of symbols that should NOT be checked.
463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -headers-list PATH
465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The file with a list of headers, that should be checked/dumped.
466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
46707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -skip-headers PATH
468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with the list of header files, that should not be checked.
469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -header NAME
471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Check/Dump ABI of this header only.
472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -use-dumps
474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Make dumps for two versions of a library and compare dumps. This should
475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      increase the performance of the tool and decrease the system memory usage.
476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -nostdinc
478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Do not search in GCC standard system directories for header files.
479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
48007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system NAME -sysroot DIR
48107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Find all the shared libraries and header files in DIR directory,
482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      create XML descriptors and make ABI dumps for each library. The result
483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      set of ABI dumps can be compared (--cmp-systems) with the other one
484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      created for other version of operating system in order to check them for
485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      compatibility. Do not forget to specify -cross-gcc option if your target
486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system requires some specific version of GCC compiler (different from
487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the host GCC). The system ABI dump will be generated to:
48807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_dumps/NAME/ARCH
489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system DESCRIPTOR.xml
491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The same as the previous option but takes an XML descriptor of the target
492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system as input, where you should describe it:
493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Primary sections */
495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <name>
497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Name of the system */
498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </name>
499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to header files and/or
502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with header files, one per line */
503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to shared libraries and/or
507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with shared libraries, one per line */
508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Optional sections */
511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_headers>
513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for header files to automatically
515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 generate include paths, one per line */
516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_headers>
517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_libs>
519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for shared libraries to resolve
521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 dependencies, one per line */
522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_libs>
523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <tools>
525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories with tools used
526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for analysis (GCC toolchain), one per line */
527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </tools>
528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <cross_prefix>
530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* GCC toolchain prefix.
531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 Examples:
532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-linux-gnueabi
533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-none-symbianelf */
534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </cross_prefix>
535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <gcc_options>
537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Additional GCC options, one per line */
538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </gcc_options>
539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
54007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysinfo DIR
54152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      This option should be used with -dump-system option to dump
54252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      ABI of operating systems and configure the dumping process.
54352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      You can find a sample in the package:
544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          modules/Targets/{unix, symbian, windows}
545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
54607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cmp-systems -d1 sys_dumps/NAME1/ARCH -d2 sys_dumps/NAME2/ARCH
547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare two system ABI dumps. Create compatibility reports for each
548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and the common HTML report including the summary of test
549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      results for all checked libraries. Report will be generated to:
55007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_compat_reports/NAME1_to_NAME2/ARCH
551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -libs-list PATH
553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with a list of libraries, that should be dumped by
554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the -dump-system option or should be checked by the -cmp-systems option.
555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -ext|-extended
557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If your library A is supposed to be used by other library B and you
558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      want to control the ABI of B, then you should enable this option. The
559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      tool will check for changes in all data types, even if they are not
560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      used by any function in the library A. Such data types are not part
561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the A library ABI, but may be a part of the ABI of the B library.
562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The short scheme is:
564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        app C (broken) -> lib B (broken ABI) -> lib A (stable ABI)
565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -q|-quiet
567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print all messages to the file instead of stdout and stderr.
568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default path (can be changed by -log-path option):
569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          $COMMON_LOG_PATH
570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -stdout
572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print analysis results (compatibility reports and ABI dumps) to stdout
573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      instead of creating a file. This would allow piping data to other programs.
574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
57507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-format FMT
576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change format of compatibility report.
577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Formats:
578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        htm - HTML format (default)
579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        xml - XML format
580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-format FMT
5825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Change format of ABI dump.
5835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Formats:
5845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        perl - Data::Dumper format (default)
5855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        xml - XML format
5865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
5871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -xml
5885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Alias for: --report-format=xml or --dump-format=xml
5891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
59007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -lang LANG
591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Set library language (C or C++). You can use this option if the tool
592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      cannot auto-detect a language. This option may be useful for checking
593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      C-library headers (--lang=C) in --headers-only or --extended modes.
59454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
59554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko  -arch ARCH
59654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      Set library architecture (x86, x86_64, ia64, arm, ppc32, ppc64, s390,
59754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      ect.). The option is useful if the tool cannot detect correct architecture
59854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko      of the input objects.
599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -binary|-bin|-abi
6011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Binary\" compatibility problems only.
6021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
60307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
6041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
6051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -source|-src|-api
6061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Source\" compatibility problems only.
6071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
60807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
609f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6102489ef88760861175102e4508089608391beead3Andrey Ponomarenko  -limit-affected LIMIT
611f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      The maximum number of affected symbols listed under the description
612f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      of the changed type in the report.
6131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOTHER OPTIONS:
615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test
616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Run internal tests. Create two binary incompatible versions of a sample
617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and run the tool to check them for compatibility. This option
61852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko      allows to check if the tool works correctly in the current environment.
619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test-dump
621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Test ability to create, read and compare ABI dumps.
622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -debug
624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Debugging mode. Print debug info on the screen. Save intermediate
625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      analysis stages in the debug directory:
62607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          debug/LIB_NAME/VERSION/
627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Also consider using --dump option for debugging the tool.
6291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -cpp-compatible
63107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      If your header files are written in C language and can be compiled
63207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      by the G++ compiler (i.e. don't use C++ keywords), then you can tell
63307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      the tool about this and speedup the analysis.
6342b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
6352b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko  -cpp-incompatible
6362b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko      Set this option if input C header files use C++ keywords.
637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
63807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -p|-params PATH
639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to file with the function parameter names. It can be used
640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for improving report view if the library header files have no
641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      parameter names. File format:
642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func1;param1;param2;param3 ...
644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func2;param1;param2;param3 ...
645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko             ...
646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
64707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath PATH
64807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the XML-descriptor used
649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for dumping the library ABI (see -dump option).
650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath1 PATH
65207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 1st XML-descriptor (-d1).
653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath2 PATH
65507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 2nd XML-descriptor (-d2).
656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
65707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-path PATH
6585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Specify a *.abi.$AR_EXT or *.abi file path where to generate an ABI dump.
659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
66007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          abi_dumps/LIB_NAME/LIB_NAME_VERSION.abi.$AR_EXT
661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -sort
66362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Enable sorting of data in ABI dumps.
66462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
66507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-path PATH
6660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      Path to compatibility report.
6671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
66807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/compat_report.html
6691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
67007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -bin-report-path PATH
6711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Binary\" compatibility report.
672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
67307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -src-report-path PATH
6761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Source\" compatibility report.
6771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
67807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
6791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
68007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log-path PATH
681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for all messages.
682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
68307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/VERSION/log.txt
684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log1-path PATH
686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 1st version of a library.
687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
68807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V1/log.txt
689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log2-path PATH
691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 2nd version of a library.
692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V2/log.txt
694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -logging-mode MODE
696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change logging mode.
697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Modes:
698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        w - overwrite old logs (default)
699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        a - append old logs
700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        n - do not write any logs
701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -list-affected
703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Generate file with the list of incompatible
704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      symbols beside the HTML compatibility report.
705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Use 'c++filt \@file' command from GNU binutils
706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      to unmangle C++ symbols in the generated file.
7071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default names:
708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          abi_affected.txt
7091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko          src_affected.txt
710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
71107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -component NAME
712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The component name in the title and summary of the HTML report.
713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          library
71552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
71614b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko  -title NAME
71707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Change library name in the report title to NAME. By default
718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      will be displayed a name specified by -l option.
71907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
72007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -extra-info DIR
72107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Dump extra info to DIR.
722570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
723570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -extra-dump
724570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create extended ABI dump containing all symbols
725570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      from the translation unit.
726570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
727570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -force
728570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Try to use this option if the tool doesn't work.
7298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerance LEVEL
7318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Apply a set of heuristics to successfully compile input
7328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      header files. You can enable several tolerance levels by
7338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      joining them into one string (e.g. 13, 124, etc.).
7348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Levels:
7358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          1 - skip non-Linux headers (e.g. win32_*.h, etc.)
7368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          2 - skip internal headers (e.g. *_p.h, impl/*.h, etc.)
7378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          3 - skip headers that iclude non-Linux headers
7388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          4 - skip headers included by others
7398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerant
7418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Enable highest tolerance level [1234].
742177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
743177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  -check
744177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      Check completeness of the ABI dump.
745e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
746e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  -quick
747e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko      Quick analysis. Disable check of some template instances.
748d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
749d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko  -skip-internal PATTERN
750d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko      Do not check internal interfaces matched by the pattern.
75162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT:
753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Compatibility report will be generated to:
75407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/compat_report.html
755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Log will be generated to:
75707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V1/log.txt
75807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V2/log.txt
759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXIT CODES:
761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    0 - Compatible. The tool has run without any errors.
762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    non-zero - Incompatible or the tool has run with errors.
763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFORMATION:
765ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    ".$HomePage."\n");
766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Operator_Indication = (
769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not" => "~",
770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assign" => "=",
771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "andassign" => "&=",
772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "orassign" => "|=",
773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xorassign" => "^=",
774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or" => "|",
775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xor" => "^",
776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "addr" => "&",
777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and" => "&",
778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lnot" => "!",
779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "eq" => "==",
780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ne" => "!=",
781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lt" => "<",
782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshift" => "<<",
783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshiftassign" => "<<=",
784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshiftassign" => ">>=",
785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "call" => "()",
786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mod" => "%",
787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "modassign" => "%=",
788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "subs" => "[]",
789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "land" => "&&",
790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lor" => "||",
791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshift" => ">>",
792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ref" => "->",
793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "le" => "<=",
794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "deref" => "*",
795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mult" => "*",
796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "preinc" => "++",
797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => " delete",
798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecnew" => " new[]",
799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecdelete" => " delete[]",
800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "predec" => "--",
801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postinc" => "++",
802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postdec" => "--",
803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plusassign" => "+=",
804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plus" => "+",
805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minus" => "-",
806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minusassign" => "-=",
807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gt" => ">",
808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ge" => ">=",
809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => " new",
810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "multassign" => "*=",
811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "divassign" => "/=",
812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "div" => "/",
813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "neg" => "-",
814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pos" => "+",
815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "memref" => "->*",
816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "compound" => "," );
817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
81862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %UnknownOperator;
81962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
82062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %NodeType= (
82162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "array_type" => "Array",
82262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "binfo" => "Other",
82362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "boolean_type" => "Intrinsic",
82462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "complex_type" => "Intrinsic",
82562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "const_decl" => "Other",
82662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "enumeral_type" => "Enum",
82762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "field_decl" => "Other",
82862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_decl" => "Other",
82962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_type" => "FunctionType",
83062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "identifier_node" => "Other",
83162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_cst" => "Other",
83262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_type" => "Intrinsic",
833177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "vector_type" => "Vector",
83462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "method_type" => "MethodType",
83562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "namespace_decl" => "Other",
83662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "parm_decl" => "Other",
83762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "pointer_type" => "Pointer",
83862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_cst" => "Other",
83962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_type" => "Intrinsic",
84062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "record_type" => "Struct",
84162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "reference_type" => "Ref",
84262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "string_cst" => "Other",
84362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "template_decl" => "Other",
844177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "template_type_parm" => "TemplateParam",
845177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "typename_type" => "TypeName",
846177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "sizeof_expr" => "SizeOf",
84762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_list" => "Other",
84862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_vec" => "Other",
84962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "type_decl" => "Other",
85062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "union_type" => "Union",
85162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "var_decl" => "Other",
85262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "void_type" => "Intrinsic",
8538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "nop_expr" => "Other", #
8548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "addr_expr" => "Other", #
85562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "offset_type" => "Other" );
85662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_C = map {$_=>1} (
858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++ 2003 keywords
859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "public",
860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "protected",
861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "private",
862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default",
863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "template",
864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new",
865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"asm",
866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic_cast",
867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "auto",
868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "try",
869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "namespace",
870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typename",
871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "using",
872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "reinterpret_cast",
873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "friend",
874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "class",
875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "virtual",
876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "const_cast",
877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mutable",
878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_cast",
879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "export",
880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++0x keywords
881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "noexcept",
882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nullptr",
883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "constexpr",
884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_assert",
885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "explicit",
886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # cannot be used as a macro name
887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # as it is an operator in C++
888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and",
889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"and_eq",
890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not",
891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"not_eq",
892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or"
893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"or_eq",
894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitand",
895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitor",
896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor",
897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor_eq",
898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"compl"
899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_F = map {$_=>1} (
902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete",
903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "catch",
904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "alignof",
905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "thread_local",
906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "decltype",
907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typeid"
908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_O = map {$_=>1} (
911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool",
912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "register",
913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inline",
914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "operator"
915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_A = map {$_=>1} (
918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "this",
9198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "throw",
9208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "template"
921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (keys(%CppKeywords_C),
924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_F),
925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_O)) {
926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CppKeywords_A{$_}=1;
927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Header file extensions as described by gcc
930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IntrinsicMangling = (
933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "void" => "v",
934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool" => "b",
935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar_t" => "w",
936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "char" => "c",
937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signed char" => "a",
938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned char" => "h",
939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "short" => "s",
940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned short" => "t",
941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "int" => "i",
942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int" => "j",
943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long" => "l",
944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long" => "m",
945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long" => "x",
946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int64" => "x",
947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long" => "y",
948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int128" => "n",
949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned __int128" => "o",
950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "float" => "f",
951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "double" => "d",
952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long double" => "e",
953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float80" => "e",
954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float128" => "g",
955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "..." => "z"
956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %IntrinsicNames = map {$_=>1} keys(%IntrinsicMangling);
959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdcxxMangling = (
961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std"=>"St",
962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std9allocator"=>"Sa",
963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_string"=>"Sb",
964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_stringIcE"=>"Ss",
965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_istreamIcE"=>"Si",
966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_ostreamIcE"=>"So",
967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std14basic_iostreamIcE"=>"Sd"
968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
970e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkomy $DEFAULT_STD_PARMS = "std::(allocator|less|char_traits|regex_traits|istreambuf_iterator|ostreambuf_iterator)";
971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %DEFAULT_STD_ARGS = map {$_=>1} ("_Alloc", "_Compare", "_Traits", "_Rx_traits", "_InIter", "_OutIter");
972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ADD_TMPL_INSTANCES = 1;
974f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $EMERGENCY_MODE_48 = 0;
97507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffix = (
977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int"=>"u",
978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long"=>"l",
979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long"=>"ul",
980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long"=>"ll",
981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long"=>"ull"
982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffixR =
985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoreverse(%ConstantSuffix);
986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OperatorMangling = (
988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "~" => "co",
989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "=" => "aS",
990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|" => "or",
991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^" => "eo",
992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&" => "an",#ad (addr)
993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "==" => "eq",
994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!" => "nt",
995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!=" => "ne",
996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<" => "lt",
997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<=" => "le",
998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<" => "ls",
999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<=" => "lS",
1000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">" => "gt",
1001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">=" => "ge",
1002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>" => "rs",
1003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>=" => "rS",
1004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "()" => "cl",
1005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%" => "rm",
1006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "[]" => "ix",
1007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&&" => "aa",
1008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "||" => "oo",
1009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*" => "ml",#de (deref)
1010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "++" => "pp",#
1011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "--" => "mm",#
1012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => "nw",
1013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => "dl",
1014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new[]" => "na",
1015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete[]" => "da",
1016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+=" => "pL",
1017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+" => "pl",#ps (pos)
1018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-" => "mi",#ng (neg)
1019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-=" => "mI",
1020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*=" => "mL",
1021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/=" => "dV",
1022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&=" => "aN",
1023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|=" => "oR",
1024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%=" => "rM",
1025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^=" => "eO",
1026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/" => "dv",
1027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->*" => "pm",
1028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->" => "pt",#rf (ref)
1029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "," => "cm",
1030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "?" => "qu",
1031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "." => "dt",
1032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sizeof"=> "sz"#st
1033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Intrinsic_Keywords = map {$_=>1} (
103662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "true",
103762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "false",
103862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Bool",
103962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Complex",
104062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "const",
104162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "int",
104262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "long",
104362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "void",
104462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "short",
104562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "float",
104662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "volatile",
104762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "restrict",
104862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "unsigned",
104962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "signed",
105062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "char",
105162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "double",
105262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "class",
105362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "struct",
105462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "union",
105562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "enum"
105662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko);
105762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcHeader = map {$_=>1} (
1059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "aliases.h",
1060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argp.h",
1061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argz.h",
1062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assert.h",
1063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "cpio.h",
1064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ctype.h",
1065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dirent.h",
1066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "envz.h",
1067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "errno.h",
1068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "error.h",
1069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "execinfo.h",
1070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fcntl.h",
1071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fstab.h",
1072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ftw.h",
1073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "glob.h",
1074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "grp.h",
1075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "iconv.h",
1076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ifaddrs.h",
1077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inttypes.h",
1078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "langinfo.h",
1079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "limits.h",
1080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "link.h",
1081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "locale.h",
1082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "malloc.h",
1083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "math.h",
1084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mntent.h",
1085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "monetary.h",
1086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nl_types.h",
1087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "obstack.h",
1088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "printf.h",
1089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pwd.h",
1090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "regex.h",
1091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched.h",
1092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "search.h",
1093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "setjmp.h",
1094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "shadow.h",
1095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signal.h",
1096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "spawn.h",
1097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdarg.h",
1098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdint.h",
1099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdio.h",
1100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdlib.h",
1101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "string.h",
11029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "strings.h",
1103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tar.h",
1104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "termios.h",
1105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "time.h",
1106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ulimit.h",
1107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unistd.h",
1108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "utime.h",
1109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar.h",
1110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wctype.h",
1111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wordexp.h" );
1112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcDir = map {$_=>1} (
1114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "arpa",
1115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bits",
1116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gnu",
1117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "netinet",
1118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "net",
1119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nfs",
1120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc",
1121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sys",
1122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "linux" );
1123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %WinHeaders = map {$_=>1} (
11259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "dos.h",
11269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "process.h",
11279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock.h",
11289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config-win.h",
11299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "mem.h",
11309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "windows.h",
11319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock2.h",
11329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "crtdbg.h",
11339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "ws2tcpip.h"
11349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
11369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ObsoleteHeaders = map {$_=>1} (
11379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "iostream.h",
11389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "fstream.h"
11399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
114174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %AlienHeaders = map {$_=>1} (
114274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Solaris
114374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "thread.h",
114474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h",
114574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # HPUX
114674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/stream.h",
114774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Symbian
114874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "AknDoc.h",
114974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Atari ST
115074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ext.h",
115174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "tos.h",
115274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # MS-DOS
115374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "alloc.h",
115474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Sparc
115574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h"
115674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
115774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
11589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ConfHeaders = map {$_=>1} (
11599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "atomic",
11609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "conf.h",
11619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config.h",
11629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "configure.h",
11639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "build.h",
11649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "setup.h"
11659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
11669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LocalIncludes = map {$_=>1} (
1168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local/include",
1169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local" );
1170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_AddPath=(
1172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# These paths are needed if the tool cannot detect them automatically
1173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "macos"=>{
1174570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1175570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1176570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/include"
1177570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1178570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1179570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1180570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/lib"
1181570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1182570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/bin"
1184570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
1186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "beos"=>{
1187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Haiku has GCC 2.95.3 by default
1188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to find GCC>=3.0 in /boot/develop/abi
1189570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common",
1191570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop"
1192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1194570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/lib",
1195570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/lib",
1196570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/apps"
1197570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1198570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1199570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/bin",
1200570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/bin",
1201570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop/abi"
1202570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Slash_Type=(
1207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"/",
1208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"\\"
1209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLASH = $Slash_Type{$OSgroup}?$Slash_Type{$OSgroup}:$Slash_Type{"default"};
1212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Global Variables
1214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %COMMON_LANGUAGE=(
1215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  1 => "C",
1216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  2 => "C" );
1217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAX_COMMAND_LINE_ARGUMENTS = 4096;
12199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $MAX_CPPFILT_FILE_SIZE = 50000;
12209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $CPPFILT_SUPPORT_FILE;
12219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy (%WORD_SIZE, %CPU_ARCH, %GCC_VERSION);
1223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $STDCXX_TESTING = 0;
1225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GLIBC_TESTING = 0;
12268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy $CPP_HEADERS = 0;
1227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckHeadersOnly = $CheckHeadersOnly_Opt;
12298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1230dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy $TargetComponent;
1231dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1232570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy $CheckUndefined = 0;
1233570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko# Set Target Component Name
1235dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoif($TargetComponent_Opt) {
1236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $TargetComponent = lc($TargetComponent_Opt);
1237dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
1238dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoelse
1239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # default: library
1240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # other components: header, system, ...
1241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TargetComponent = "library";
1242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
124452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy $TOP_REF = "<a class='top_ref' href='#Top'>to the top</a>";
12451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SystemRoot;
1247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAIN_CPP_DIR;
12491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %RESULT;
1250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LOG_PATH;
1251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DEBUG_PATH;
1252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Cache;
1253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LibInfo;
1254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMPILE_ERRORS = 0;
1255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompilerOptions;
1256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedDyLib;
1257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TargetLibraryShortName = parse_libname($TargetLibraryName, "shortest", $OSgroup);
1258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Constants (#defines)
1260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Constants;
1261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipConstants;
126282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkomy %EnumConstants;
1263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
126474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko# Extra Info
126574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %SymbolHeader;
126674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %KnownLibs;
126774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1268177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Templates
1269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TemplateInstance;
1270177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %BasicTemplate;
1271177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateArg;
1272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkomy %TemplateDecl;
1273177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateMap;
1274177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1275177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Types
1276177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TypeInfo;
1277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipTypes = (
1278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedTypes;
1281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TName_Tid;
1282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %EnumMembName_Id;
1283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %NestedNameSpaces = (
1284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualTable;
12871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VirtualTable_Model;
1288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable;
1289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable_Content;
1290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VTableClass;
1291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AllocableClass;
1292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassMethods;
12931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %ClassNames;
1294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Class_SubClasses;
1295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OverriddenMethods;
12964b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %TypedefToAnon;
129762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy $MAX_ID = 0;
1298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1299177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %CheckedTypeInfo;
1300177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Typedefs
1302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_BaseName;
1303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Tr;
1304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Eq;
1305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdCxxTypedef;
1306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MissedTypedef;
130762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase;
130862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase_R;
13099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TypeTypedef;
1310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols
1312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolInfo;
1313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %tr_name;
1314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name_gcc;
1315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name;
1316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipSymbols = (
1317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipNameSpaces = (
1320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1322a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenkomy %AddNameSpaces = (
1323a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "1"=>{},
1324a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "2"=>{} );
1325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList;
132652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkomy %TypesList;
1327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList_App;
1328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedSymbols;
132962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Symbol_Library = (
133062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
133162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
133262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Library_Symbol = (
133362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
133462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
133562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepSymbol_Library = (
133662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
133762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
133862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepLibrary_Symbol = (
1339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MangledNames;
13429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %Func_ShortName;
1343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddIntParams;
134462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %GlobalDataObject;
134507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %WeakSymbols;
1346fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Library_Needed= (
1347fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "1"=>{},
1348fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "2"=>{} );
1349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko# Extra Info
1351570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %UndefinedSymbols;
135274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %PreprocessedHeaders;
1353570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Headers
1355570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Preamble = (
1356570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1357570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Registered_Headers;
1359fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Registered_Sources;
1360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HeaderName_Paths;
1361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Dependency;
1362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Neighbors;
1363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Paths = (
1364570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1365570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %INC_PATH_AUTODETECT = (
1367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>1,
1368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>1 );
1369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Add_Include_Paths = (
1370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Skip_Include_Paths;
1373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RegisteredDirs;
1374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ErrorRedirect;
1375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Includes;
13768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %Header_Includes_R;
1377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ShouldNotBeUsed;
1378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RecursiveIncludes;
1379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Include_Prefix;
1380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeaders;
1381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeadersList=(
1382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipLibs;
1385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Order;
1386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TUnit_NameSpaces;
1387f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %TUnit_Classes;
13889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Funcs;
13899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Vars;
1390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
139107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %CppMode = (
1392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AutoPreambleMode = (
1395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MinGWMode = (
1398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
140001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %Cpp0xMode = (
140101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "1"=>0,
140201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "2"=>0 );
1403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Shared Objects
14059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObjects;
140607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %RegisteredObjects_Short;
14079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredSONAMEs;
14089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObject_Dirs;
1409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1410d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkomy %CheckedArch;
1411d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Objects
1413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemObjects;
1414570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultLibPaths;
14159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %DyLib_DefaultPath;
1416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Headers
1418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemHeaders;
1419570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultCppPaths;
1420570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultGccPaths;
1421570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultIncPaths;
1422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultCppHeader;
1423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultGccHeader;
1424570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @UsersIncPath;
1425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Merging
1427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompleteSignature;
1428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Version;
1429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt;
1430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt;
1431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt_Virt;
1432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt_Virt;
1433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualReplacement;
1434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ChangedTypedef;
1435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatRules;
1436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IncompleteRules;
1437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %UnknownRules;
14381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VTableChanged_M;
143962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %ExtendedSymbols;
1440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ReturnedClass;
1441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ParamClass;
14421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative;
14431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative_B;
14441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceReplacement;
1445f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $CurrentSymbol; # for debugging
1446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1447f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko# Calling Conventions
1448f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %UseConv_Real = (
1449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  1=>{ "R"=>0, "P"=>0 },
1450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  2=>{ "R"=>0, "P"=>0 }
1451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko);
1452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko# ABI Dump
1454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %UsedDump;
1455f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
14566fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Filters
1457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetLibs;
1458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetHeaders;
1459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14606fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko# Format of objects
1461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OStarget = $OSgroup;
1462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetTools;
1463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Compliance Report
1465dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy %Type_MaxSeverity;
1466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Recursion locks
1468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurLib;
1469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurTypes;
14708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy @RecurTypes_Diff;
1471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurInclude;
1472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurConstant;
1473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System
1475570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %SystemPaths = (
1476570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "include"=>[],
1477570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "lib"=>[],
1478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "bin"=>[]
1479570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
1480570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultBinPaths;
1481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GCC_PATH;
1482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols versioning
1484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymVer = (
1485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Problem descriptions
1489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatProblems;
14908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Constants;
1491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TotalAffected;
1492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Reports
1494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentID = 1;
1495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart = "<span class=\"section\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Affected = "<span class=\"section_affected\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Info = "<span class=\"section_info\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanEnd = "</span>\n";
1499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivStart = "<div id=\"CONTENT_ID\" style=\"display:none;\">\n";
1500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivEnd = "</div>\n";
1501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Content_Counter = 0;
1502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Modes
15041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $JoinReport = 1;
15051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $DoubleReport = 0;
1506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15072489ef88760861175102e4508089608391beead3Andrey Ponomarenkomy %Severity_Val=(
15082489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "High"=>3,
15092489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Medium"=>2,
15102489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Low"=>1,
15112489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Safe"=>-1
15122489ef88760861175102e4508089608391beead3Andrey Ponomarenko);
15132489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Modules()
1515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TOOL_DIR = get_dirname($0);
1517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TOOL_DIR)
1518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # patch for MS Windows
1519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TOOL_DIR = ".";
1520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SEARCH_DIRS = (
1522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # tool's directory
1523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR),
1524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # relative path to modules
1525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR)."/../share/abi-compliance-checker",
152674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        # install path
152774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        'MODULES_INSTALL_PATH'
1528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
1529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $DIR (@SEARCH_DIRS)
1530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not is_abs($DIR))
1532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative path
1533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $DIR = abs_path($TOOL_DIR)."/".$DIR;
1534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $DIR."/modules") {
1536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $DIR."/modules";
1537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitStatus("Module_Error", "can't find modules");
1540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %LoadedModules = ();
154301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub loadModule($)
1545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
154701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $LoadedModules{$Name}) {
154801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return;
154901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Name.pm";
1551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $Path) {
1552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    require $Path;
155501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $LoadedModules{$Name} = 1;
1556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub readModule($$)
1559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
1560570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Module, $Name) = @_;
1561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
1562570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not -f $Path) {
1563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
1565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return readFile($Path);
1566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
1567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
15680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showPos($)
1569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1570dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Number = $_[0];
1571dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Number) {
1572dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = 1;
1573dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1574dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    else {
1575dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = int($Number)+1;
1576dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Number>3) {
1578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number."th";
1579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==1) {
1581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "1st";
1582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==2) {
1584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "2nd";
1585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==3) {
1587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "3rd";
1588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number;
1591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Tools($)
1595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Paths = keys(%TargetTools))
1599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (@Paths)
1601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
160274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-f join_P($Path, $Name)) {
160374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($Path, $Name);
1604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossPrefix)
1606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # user-defined prefix (arm-none-symbianelf, ...)
160774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $Candidate = join_P($Path, $CrossPrefix."-".$Name);
1608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
1610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub synch_Cmd($)
1620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GCC_PATH)
1623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC was not found yet
1624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Candidate = $GCC_PATH;
162762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Candidate=~s/\bgcc(|\.\w+)\Z/$Name$1/) {
1628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Candidate;
1629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
1631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath($)
1634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_CmdPath"}{$Name}) {
1638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_CmdPath"}{$Name};
1639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %BinUtils = map {$_=>1} (
1641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "c++filt",
1642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "objdump",
1643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "readelf"
1644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
164562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($BinUtils{$Name} and $GCC_PATH)
164662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($GCC_PATH)) {
1648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetTools{$Dir}=1;
1649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = search_Tools($Name);
1652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows") {
1653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Tools($Name.".exe");
1654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossPrefix)
1658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user-defined prefix
1659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = search_Cmd($CrossPrefix."-".$Name);
1660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Candidate = synch_Cmd($Name))
1665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # synch with GCC
1666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Candidate=~/[\/\\]/)
16671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command path
1668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path = $Candidate;
1670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Candidate = search_Cmd($Candidate))
16731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command name
1674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Candidate;
1675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path) {
1679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Cmd($Name);
1680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows")
16821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for *.exe file
1683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=search_Cmd($Name.".exe");
1684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\s/) {
1686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = "\"".$Path."\"";
1687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_CmdPath"}{$Name}=$Path);
1689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Cmd($)
1692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"search_Cmd"}{$Name}) {
1696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"search_Cmd"}{$Name};
1697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DefaultPath = get_CmdPath_Default($Name)) {
1699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Cache{"search_Cmd"}{$Name} = $DefaultPath);
1700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1701570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"bin"}})
1702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
170374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $CmdPath = join_P($Path,$Name);
1704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $CmdPath)
1705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name=~/gcc/) {
170762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(not check_gcc($CmdPath, "3"));
1708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"search_Cmd"}{$Name} = $CmdPath);
1710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"search_Cmd"}{$Name} = "");
1713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath_Default($)
1716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search in PATH
171762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $_[0]);
171862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_CmdPath_Default"}{$_[0]}) {
171962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_CmdPath_Default"}{$_[0]};
1720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
172162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_CmdPath_Default"}{$_[0]} = get_CmdPath_Default_I($_[0]));
172262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
172362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
172462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_CmdPath_Default_I($)
172562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # search in PATH
172662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Name = $_[0];
1727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/find/)
1728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # special case: search for "find" utility
1729a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`find \"$TMP_DIR\" -maxdepth 0 2>\"$TMP_DIR/null\"`) {
173062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "find";
1731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/gcc/) {
173462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return check_gcc($Name, "3");
1735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1736570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(checkCmd($Name)) {
173762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Name;
1738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
173962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($OSgroup eq "windows")
174062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1741a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`$Name /? 2>\"$TMP_DIR/null\"`) {
174262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Name;
174362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1745570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultBinPaths)
1746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Name) {
174874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path, $Name);
1749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
1752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub classifyPath($)
1755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
1757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/[\*\[]/)
1758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # wildcard
1759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\*/.*/g;
1760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\\\\/g;
1761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Pattern");
1762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Path=~/[\/\\]/)
1764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory or relative path
1765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return (path_format($Path, $OSgroup), "Path");
1766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Name");
1769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readDescriptor($$)
1773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Content) = @_;
1775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion);
1776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DName = $DumpAPI?"descriptor":"descriptor \"d$LibVersion\"";
1777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Content) {
1778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "$DName is empty");
1779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content!~/\</) {
17815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        exitStatus("Error", "incorrect descriptor (see -d1 option)");
1782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\/\*(.|\n)+?\*\///g;
1784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/<\!--(.|\n)+?-->//g;
1785570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = parseTag(\$Content, "version");
1787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetVersion{$LibVersion}) {
1788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $TargetVersion{$LibVersion};
1789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{$LibVersion}{"Version"}) {
1791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "version in the $DName is not specified (<version> section)");
1792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/{RELPATH}/)
1794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RelDir = $RelativeDirectory{$LibVersion}) {
1796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Content =~ s/{RELPATH}/$RelDir/g;
1797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
1799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NeedRelpath = $DumpAPI?"-relpath":"-relpath$LibVersion";
1801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "you have not specified $NeedRelpath option, but the $DName contains {RELPATH} macro");
1802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1805ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $DHeaders = parseTag(\$Content, "headers");
1806ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $DHeaders) {
1807ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "header files in the $DName are not specified (<headers> section)");
1808ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
1809ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    elsif(lc($DHeaders) ne "none")
1810ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # append the descriptor headers list
1811ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Headers"})
1812ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # multiple descriptors
1813ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} .= "\n".$DHeaders;
1814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1815ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
1816ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $Descriptor{$LibVersion}{"Headers"} = $DHeaders;
1817ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
1818ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, $DHeaders))
1819ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
1820ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not -e $Path) {
1821ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$Path\'");
1822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1825ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckHeadersOnly_Opt)
1827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DObjects = parseTag(\$Content, "libs");
1829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DObjects) {
1830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries in the $DName are not specified (<libs> section)");
1831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DObjects) ne "none")
1833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor libraries list
1834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Libs"})
1835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= "\n".$DObjects;
1837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= $DObjects;
1840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DObjects))
1842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_headers")))
1850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1856570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"include"}, $Path);
1857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_libs")))
1859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1865570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, $Path);
1866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "tools")))
1868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1874570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, $Path);
1875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetTools{$Path}=1;
1876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Prefix = parseTag(\$Content, "cross_prefix")) {
1878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CrossPrefix = $Prefix;
1879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1880570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"IncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"IncludePaths"}); # perl 5.8 doesn't support //=
1881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "include_paths")))
1882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
1884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
1885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
1887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
1888570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"IncludePaths"}}, $Path);
1889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1890570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"AddIncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"AddIncludePaths"});
1891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "add_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}{"AddIncludePaths"}}, $Path);
1899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_include_paths")))
19018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip some auto-generated include paths
19028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not is_abs($Path))
19038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
19048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $P = abs_path($Path)) {
19058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Path = $P;
19068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
19078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
1908570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $Skip_Include_Paths{$LibVersion}{path_format($Path)} = 1;
1909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_including")))
19118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip direct including of some headers
1912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 2;
1914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"GccOptions"} = parseTag(\$Content, "gcc_options");
191674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    foreach my $Option (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"GccOptions"}))
191774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
19188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Option!~/\A\-(Wl|l|L)/)
19198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # skip linker options
192074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $CompilerOptions{$LibVersion} .= " ".$Option;
192174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
1924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipHeaders"}))
1925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = 1;
1927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 1;
1929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipLibs"} = parseTag(\$Content, "skip_libs");
1931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipLibs"}))
1932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipLibs{$LibVersion}{$Type}{$CPath} = 1;
1935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DDefines = parseTag(\$Content, "defines"))
1937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Defines"})
1939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # multiple descriptors
1940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} .= "\n".$DDefines;
1941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} = $DDefines;
1944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
1947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Order=~/\A(.+):(.+)\Z/) {
1949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Order{$LibVersion}{$1} = $2;
1950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")),
1953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_types")))
19541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # opaque_types renamed to skip_types (1.23.4)
1955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipTypes{$LibVersion}{$Type_Name} = 1;
1956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
1958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
19591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # skip_interfaces renamed to skip_symbols (1.22.1)
1960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipSymbols{$LibVersion}{$Symbol} = 1;
1961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "skip_namespaces"))) {
1963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipNameSpaces{$LibVersion}{$NameSpace} = 1;
1964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1965a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "add_namespaces"))) {
1966a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $AddNameSpaces{$LibVersion}{$NameSpace} = 1;
1967a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
1968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (split(/\s*\n\s*/, parseTag(\$Content, "skip_constants"))) {
1969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipConstants{$LibVersion}{$Constant} = 1;
1970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DIncPreamble = parseTag(\$Content, "include_preamble"))
1972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"IncludePreamble"})
19741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # multiple descriptors
1975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} .= "\n".$DIncPreamble;
1976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} = $DIncPreamble;
1979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
198301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub parseTag(@)
1984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
198501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $CodeRef = shift(@_);
198601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Tag = shift(@_);
198701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Tag or not $CodeRef) {
198801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return undef;
198901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
199001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Sp = 0;
199101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(@_) {
199201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Sp = shift(@_);
199301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
199401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Start = index(${$CodeRef}, "<$Tag>");
199501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Start!=-1)
1996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
199701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $End = index(${$CodeRef}, "</$Tag>");
199801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($End!=-1)
199901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
200001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $TS = length($Tag)+3;
200101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Content = substr(${$CodeRef}, $Start, $End-$Start+$TS, "");
200201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, 0, $TS-1, ""); # cut start tag
200301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, -$TS, $TS, ""); # cut end tag
200401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not $Sp)
200501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
200601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\A\s+//g;
200701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\s+\Z//g;
200801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
200901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(substr($Content, 0, 1) ne "<") {
201001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content = xmlSpecChars_R($Content);
201101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
201201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Content;
201301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
201501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return undef;
201601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
201701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getInfo($)
2019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2020850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2021850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $DumpPath or not -f $DumpPath);
2022850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2023850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    readTUDump($DumpPath);
2024850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing info
2026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTemplateParams_All();
20274b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
202874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
20294b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        setAnonTypedef_All();
20304b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
20314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getTypeInfo_All();
2033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    simplifyNames();
203482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    simplifyConstants();
2035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getVarInfo_All();
203601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    getSymbolInfo_All();
2037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2038850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %LibInfo = ();
2040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %TemplateInstance = ();
2041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    %BasicTemplate = ();
2042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %MangledNames = ();
2043850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %TemplateDecl = ();
2044850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %StdCxxTypedef = ();
2045850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %MissedTypedef = ();
2046850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Tr = ();
2047850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Eq = ();
20484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    %TypedefToAnon = ();
2049850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
205062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clean cache
205162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeAttr"});
205262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeDeclId"});
205362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
205474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
2055570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        remove_Unused($Version, "Extra");
205774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
205874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
205974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # remove unused types
2060570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($BinaryOnly and not $ExtendedCheck)
2061570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # --binary
2062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "All");
2063570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
2064570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        else {
2065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "Extended");
2066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckInfo)
2070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$Version}})) {
2072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($TypeInfo{$Version}{$Tid}, $Version);
2073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (keys(%{$SymbolInfo{$Version}})) {
2076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($SymbolInfo{$Version}{$Sid}, $Version);
2077570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
207862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
207962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug) {
2081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # debugMangling($Version);
2082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2085850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub readTUDump($)
2086850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
2087850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2088850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2089850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    open(TU_DUMP, $DumpPath);
2090850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    local $/ = undef;
2091850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Content = <TU_DUMP>;
2092850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    close(TU_DUMP);
2093850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2094850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    unlink($DumpPath);
2095850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2096850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Content=~s/\n[ ]+/ /g;
2097d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Lines = split(/\n/, $Content);
2098850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2099850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2100850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef $Content;
2101850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $MAX_ID = $#Lines+1; # number of lines == number of nodes
2103850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2104850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (0 .. $#Lines)
2105850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
210662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Lines[$_]=~/\A\@(\d+)[ ]+([a-z_]+)[ ]+(.+)\Z/i)
2107850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # get a number and attributes of a node
2108850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next if(not $NodeType{$2});
2109850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info_type"}{$1}=$2;
2110850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info"}{$1}=$3;
2111850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2112850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
2114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($Lines[$_]);
2115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2117850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef @Lines;
2119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
2120850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
212182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkosub simplifyConstants()
212282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko{
212382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
212482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
2125fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$Version}{$Constant}{"Header"})
2126fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
2127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Value = $Constants{$Version}{$Constant}{"Value"};
2128fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $EnumConstants{$Version}{$Value}) {
2129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Constants{$Version}{$Constant}{"Value"} = $EnumConstants{$Version}{$Value}{"Value"};
2130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
213182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
213282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
213382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko}
213482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
2135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simplifyNames()
2136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Base (keys(%{$Typedef_Tr{$Version}}))
2138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2139f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Typedef_Eq{$Version}{$Base}) {
2140f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next;
2141f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2142f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my @Translations = sort keys(%{$Typedef_Tr{$Version}{$Base}});
2143f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($#Translations==0)
2144f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
2145f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(length($Translations[0])<=length($Base)) {
2146f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $Typedef_Eq{$Version}{$Base} = $Translations[0];
2147f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2148f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2149f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else
2150f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # select most appropriate
2151f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            foreach my $Tr (@Translations)
2152f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
2153f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Base=~/\A\Q$Tr\E/)
2154f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
2155f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $Typedef_Eq{$Version}{$Base} = $Tr;
2156f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    last;
2157f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
2158f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2161b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$Version}}))
2162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2163b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $TypeName = $TypeInfo{$Version}{$TypeId}{"Name"};
216462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TypeName) {
216562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
216662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
216762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        next if(index($TypeName,"<")==-1);# template instances only
216862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeName=~/>(::\w+)+\Z/)
216962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip unused types
217062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
2171f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
217262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Base (sort {length($b)<=>length($a)}
217362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        sort {$b cmp $a} keys(%{$Typedef_Eq{$Version}}))
217462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
217562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(not $Base);
217662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(index($TypeName,$Base)==-1);
217762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(length($TypeName) - length($Base) <= 3);
2178f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(my $Typedef = $Typedef_Eq{$Version}{$Base})
2179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2180f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\W|\Z)/$1$Typedef$2/g;
2181f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\w|\Z)/$1$Typedef $2/g;
2182f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(defined $TypeInfo{$Version}{$TypeId}{"TParam"})
2183850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
2184f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    foreach my $TPos (keys(%{$TypeInfo{$Version}{$TypeId}{"TParam"}}))
2185f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
2186f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(my $TPName = $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"})
2187f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
2188f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\W|\Z)/$Typedef$1/g;
2189f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\w|\Z)/$Typedef $1/g;
21909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"} = formatName($TPName, "T");
2191f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
2192f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
2193850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
2194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeName = formatName($TypeName, "T");
2197b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TypeInfo{$Version}{$TypeId}{"Name"} = $TypeName;
2198b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypeName} = $TypeId;
2199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22024b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub setAnonTypedef_All()
22034b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko{
22044b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $InfoId (keys(%{$LibInfo{$Version}{"info"}}))
22054b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
22064b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$InfoId} eq "type_decl")
22074b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        {
22084b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(isAnon(getNameByInfo($InfoId))) {
22094b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $TypedefToAnon{getTypeId($InfoId)} = 1;
22104b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
22114b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
22124b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
22134b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko}
22144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams_All()
2216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (keys(%{$LibInfo{$Version}{"info"}}))
2218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "template_decl") {
2220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setTemplateParams($_);
2221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams($)
2226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2227177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tid = getTypeId($_[0]);
2228989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
2229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2230989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/(inst|spcs)[ ]*:[ ]*@(\d+) /)
2231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
223262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TmplInst_Id = $2;
2233177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            setTemplateInstParams($_[0], $TmplInst_Id);
223462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            while($TmplInst_Id = getNextElem($TmplInst_Id)) {
2235177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                setTemplateInstParams($_[0], $TmplInst_Id);
2236177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2237177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2238177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2239177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $BasicTemplate{$Version}{$Tid} = $_[0];
2240177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2241177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Prms = getTreeAttr_Prms($_[0]))
2242177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2243177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Valu = getTreeAttr_Valu($Prms))
2244177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2245177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Vector = getTreeVec($Valu);
2246177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Vector}))
2247177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2248177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Val = getTreeAttr_Valu($Vector->{$Pos}))
2249177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2250177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Name = getNameByInfo($Val))
2251177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2252177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TemplateArg{$Version}{$_[0]}{$Pos} = $Name;
2253177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if($LibInfo{$Version}{"info_type"}{$Val} eq "parm_decl") {
2254177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = $Val;
2255177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2256177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            else {
2257177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = getTreeAttr_Type($Val);
2258177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2259177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2260177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2261177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2262989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
2263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $TypeId = getTreeAttr_Type($_[0]))
2266850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
2267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $IType = $LibInfo{$Version}{"info_type"}{$TypeId})
2268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
2269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($IType eq "record_type") {
2270177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TemplateDecl{$Version}{$TypeId} = 1;
2271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2273850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2276177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub setTemplateInstParams($$)
2277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2278177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tmpl, $Inst) = @_;
2279177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2280177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$Inst})
2281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2282989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my ($Params_InfoId, $ElemId) = ();
2283989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
2284989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $Params_InfoId = $1;
2285989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2286989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
2287989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $ElemId = $1;
2288989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2289989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Params_InfoId and $ElemId)
2290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Params_Info = $LibInfo{$Version}{"info"}{$Params_InfoId};
2292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($Params_Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
2293989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2294989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my ($PPos, $PTypeId) = ($1, $2);
2295989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if(my $PType = $LibInfo{$Version}{"info_type"}{$PTypeId})
2296989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
2297177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($PType eq "template_type_parm") {
2298177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateDecl{$Version}{$ElemId} = 1;
2299989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
2300989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2301850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($LibInfo{$Version}{"info_type"}{$ElemId} eq "function_decl")
2302850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # functions
230362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Func"}{$ElemId}{$PPos} = $PTypeId;
2304177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2305989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2306850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else
2307850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # types
230862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Type"}{$ElemId}{$PPos} = $PTypeId;
2309177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2310989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeDeclId($)
2317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
231862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0])
2319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
232062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $Cache{"getTypeDeclId"}{$Version}{$_[0]}) {
232162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Cache{"getTypeDeclId"}{$Version}{$_[0]};
232262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
232362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
232462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
232562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+)/) {
232662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = $1);
232762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2328dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
2329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = 0);
2331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeInfo_All()
2334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
233562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # missed typedefs: QStyle::State is typedef to QFlags<QStyle::StateFlag>
2338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # but QStyleOption.state is of type QFlags<QStyle::StateFlag> in the TU dump
2339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: check GCC versions
2340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Pre();
2341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
234262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
23440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # forward order only
2345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IType = $LibInfo{$Version}{"info_type"}{$_};
2346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($IType=~/_type\Z/ and $IType ne "function_type"
2347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $IType ne "method_type") {
234862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getTypeInfo("$_");
2349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
235162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
235262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # add "..." type
235301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TypeInfo{$Version}{"-1"} = {
235462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Name" => "...",
235562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Type" => "Intrinsic",
235601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        "Tid" => "-1"
235762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    };
235801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TName_Tid{$Version}{"..."} = "-1";
235962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
236062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Post();
2363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2364177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2365177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
2366177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2367177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
2368177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}}))
2369177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2370177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Tid}
2371177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not defined $TypeInfo{$Version}{$Tid}{"Template"})
2372177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2373177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Memb"})
2374177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2375177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Memb"}}))
2376177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2377177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"})
2378177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2379177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if(my %MAttr = getTypeAttr($MembTypeId))
2380177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            {
2381177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"algn"} = $MAttr{"Algn"};
2382177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"} = instType($TemplateMap{$Version}{$Tid}, $MembTypeId, $Version);
2383177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2384177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2385177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2386177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2387177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Base"})
2388177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2389177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Bid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Base"}}))
2390177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2391177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $NBid = instType($TemplateMap{$Version}{$Tid}, $Bid, $Version);
2392177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2393177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($NBid ne $Bid)
2394177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2395177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            %{$TypeInfo{$Version}{$Tid}{"Base"}{$NBid}} = %{$TypeInfo{$Version}{$Tid}{"Base"}{$Bid}};
2396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            delete($TypeInfo{$Version}{$Tid}{"Base"}{$Bid});
2397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2399177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2400177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2404177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub createType($$)
2406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
2407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Attr, $LibVersion) = @_;
2408177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $NewId = ++$MAX_ID;
2409177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2410082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko    $Attr->{"Tid"} = $NewId;
2411177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $TypeInfo{$Version}{$NewId} = $Attr;
2412e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $TName_Tid{$Version}{formatName($Attr->{"Name"}, "T")} = $NewId;
2413177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2414177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "$NewId";
2415177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2417177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub instType($$$)
2418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{ # create template instances
2419177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Map, $Tid, $LibVersion) = @_;
2420be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko
2421be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    if(not $TypeInfo{$LibVersion}{$Tid}) {
2422be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko        return undef;
2423be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    }
2424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Attr = dclone($TypeInfo{$LibVersion}{$Tid});
2425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Key (sort keys(%{$Map}))
2427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2428177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Val = $Map->{$Key})
2429177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2430177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/\b$Key\b/$Val/g;
2431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2432177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/\b$Key\b/$Val/g;
2434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}})) {
2436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"TParam"}{$_}{"name"}=~s/\b$Key\b/$Val/g;
2437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
2440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # remove absent
2441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko          # _Traits, etc.
2442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/,\s*\b$Key(,|>)/$1/g;
2443e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/,\s*\b$Key(,|>)/$1/g;
2445177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2446177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}}))
2447177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Attr->{"TParam"}{$_}{"name"} eq $Key) {
2449177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($Attr->{"TParam"}{$_});
2450177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2451e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                else {
2452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Attr->{"TParam"}{$_}{"name"}=~s/,\s*\b$Key(,|>)/$1/g;
2453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2454177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = 0;
2459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Attr->{"TParam"})
2461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (sort {int($a)<=>int($b)} keys(%{$Attr->{"TParam"}}))
2463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $PName = $Attr->{"TParam"}{$_}{"name"};
2465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $PTid = $TName_Tid{$LibVersion}{$PName})
2467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Base = get_BaseType($PTid, $LibVersion);
2469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Base{"Type"} eq "TemplateParam"
2471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or defined $Base{"Template"})
2472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Tmpl = 1;
2474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last
2475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2478177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2480177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Id = getTypeIdByName($Attr->{"Name"}, $LibVersion)) {
2481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return "$Id";
2482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else
2484177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $Tmpl) {
2486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($Attr->{"Template"});
2487177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2489e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my $New = createType($Attr, $LibVersion);
2490e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
2491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %EMap = ();
2492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(defined $TemplateMap{$LibVersion}{$Tid}) {
2493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %EMap = %{$TemplateMap{$LibVersion}{$Tid}};
2494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Map})) {
2496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $EMap{$_} = $Map->{$_};
2497177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2499e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"BaseType"}) {
2500e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"BaseType"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"BaseType"}, $LibVersion);
2501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2502e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Base"})
2503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2504e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$New}{"Base"}}))
2505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NBid = instType(\%EMap, $Bid, $LibVersion);
2507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($NBid ne $Bid)
2509177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2510e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$New}{"Base"}{$NBid}} = %{$TypeInfo{$LibVersion}{$New}{"Base"}{$Bid}};
2511e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$New}{"Base"}{$Bid});
2512177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2513177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2516e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Memb"})
2517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2518be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Memb"}}))
2519be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            {
2520be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}) {
2521be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}, $LibVersion);
2522be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                }
2523177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2524177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2526e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Param"})
2527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2528e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Param"}})) {
2529e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"}, $LibVersion);
2530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2533e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Return"}) {
2534e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"Return"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Return"}, $LibVersion);
2535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2537e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        return $New;
2538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Pre()
2542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
254362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %MissedTypes = ();
2544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MissedTDid (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
2545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detecting missed typedefs
2546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$MissedTDid} eq "type_decl")
2547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
254862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeId = getTreeAttr_Type($MissedTDid);
2549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypeId);
255062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeType = getTypeType($TypeId);
2551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeType eq "Unknown")
2552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # template_type_parm
2553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypeDeclId = getTypeDeclId($TypeId);
2556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypeDeclId eq $MissedTDid);#or not $TypeDeclId
2557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypedefName = getNameByInfo($MissedTDid);
2558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypedefName);
2559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypedefName eq "__float80");
2560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(isAnon($TypedefName));
2561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TypeDeclId
2562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or getNameByInfo($TypeDeclId) ne $TypedefName) {
256362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MissedTypes{$Version}{$TypeId}{$MissedTDid} = 1;
2564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2567b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my %AddTypes = ();
256862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$MissedTypes{$Version}}))
2569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add missed typedefs
257062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Missed = keys(%{$MissedTypes{$Version}{$Tid}});
2571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Missed or $#Missed>=1) {
2572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MissedTDid = $Missed[0];
2575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypedefName, $TypedefNS) = getTrivialName($MissedTDid, $Tid);
2576b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $TypedefName) {
2577b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            next;
2578b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        }
2579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $NewId = ++$MAX_ID;
2580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MissedInfo = ( # typedef info
2581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Name" => $TypedefName,
2582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "NameSpace" => $TypedefNS,
2583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            "BaseType" => $Tid,
2584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Type" => "Typedef",
2585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            "Tid" => "$NewId" );
2586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($H, $L) = getLocation($MissedTDid);
2587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Header"} = $H;
2588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Line"} = $L;
2589b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/\*|\&|\s/)
2590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # other types
2591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2593b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/>(::\w+)+\Z/)
2594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # QFlags<Qt::DropAction>::enum_type
2595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
259762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(getTypeType($Tid)=~/\A(Intrinsic|Union|Struct|Enum|Class)\Z/)
2598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # double-check for the name of typedef
259962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my ($TName, $TNS) = getTrivialName(getTypeDeclId($Tid), $Tid); # base type info
2600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TName);
2601b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(length($TypedefName)>=length($TName))
2602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too long typedef
2603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2605b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TName=~/\A\Q$TypedefName\E</) {
2606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2608b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TypedefName=~/\A\Q$TName\E/)
2609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # QDateTimeEdit::Section and QDateTimeEdit::Sections::enum_type
2610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2612b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(get_depth($TypedefName)==0 and get_depth($TName)!=0)
2613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # std::_Vector_base and std::vector::_Base
2614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2617b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2618b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $AddTypes{$MissedInfo{"Tid"}} = \%MissedInfo;
2619b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # register typedef
2621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"Tid"} = $MissedInfo{"Tid"};
262262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"TDid"} = $MissedTDid;
2623b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypedefName} = $MissedInfo{"Tid"};
2624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2625b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2626b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    # add missed & remove other
2627b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    $TypeInfo{$Version} = \%AddTypes;
2628b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    delete($Cache{"getTypeAttr"}{$Version});
2629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Post()
2632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (keys(%{$MissedTypedef{$Version}}))
2634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
263562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Tid = $MissedTypedef{$Version}{$BaseId}{"Tid"})
263662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
263762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$Version}{$Tid}{"Size"} = $TypeInfo{$Version}{$BaseId}{"Size"};
263862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $TName = $TypeInfo{$Version}{$Tid}{"Name"}) {
263962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Typedef_BaseName{$Version}{$TName} = $TypeInfo{$Version}{$BaseId}{"Name"};
264062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
264162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
264562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeInfo($)
2646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2647b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TypeId = $_[0];
2648b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    %{$TypeInfo{$Version}{$TypeId}} = getTypeAttr($TypeId);
2649b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TName = $TypeInfo{$Version}{$TypeId}{"Name"};
2650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TName) {
2651b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        delete($TypeInfo{$Version}{$TypeId});
2652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArraySize($$)
2656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $BaseName) = @_;
265862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Size = getSize($TypeId))
2659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
266062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Elems = $Size/$BYTE_SIZE;
266162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($BaseName=~s/\s*\[(\d+)\]//) {
266262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Elems/=$1;
2663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
266462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BasicId = $TName_Tid{$Version}{$BaseName})
266562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
266662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $BasicSize = $TypeInfo{$Version}{$BasicId}{"Size"}) {
266762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Elems/=$BasicSize;
266862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
267062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Elems;
2671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
267262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
2673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTParams($$)
2676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
267762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $Kind) = @_;
267862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @TmplParams = ();
267962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @Positions = sort {int($a)<=>int($b)} keys(%{$TemplateInstance{$Version}{$Kind}{$TypeId}});
268062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (@Positions)
2681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
268262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Param_TypeId = $TemplateInstance{$Version}{$Kind}{$TypeId}{$Pos};
268362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $NodeType = $LibInfo{$Version}{"info_type"}{$Param_TypeId};
268462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $NodeType)
268562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # typename_type
2686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
268862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($NodeType eq "tree_vec")
268962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
269062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Pos!=$#Positions)
269162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # select last vector of parameters ( ns<P1>::type<P2> )
269262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next;
269362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
269462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
269562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = get_TemplateParam($Pos, $Param_TypeId);
269662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P (@Params)
269762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
269862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P eq "") {
269962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
270062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
270162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($P ne "\@skip\@") {
270262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @TmplParams = (@TmplParams, $P);
270362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
270662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return @TmplParams;
2707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
270962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeAttr($)
2710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
271162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
27120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my %TypeAttr = ();
271362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TypeInfo{$Version}{$TypeId}
271462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $TypeInfo{$Version}{$TypeId}{"Name"})
271562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # already created
271662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$TypeInfo{$Version}{$TypeId}};
2717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
271862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($Cache{"getTypeAttr"}{$Version}{$TypeId})
271962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incomplete type
272062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ();
272162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
272262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"getTypeAttr"}{$Version}{$TypeId} = 1;
272362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
272462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
2725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
272662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
272762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $MissedBase{$Version}{$TypeId} and isTypedef($TypeId))
272862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
272962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
273062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
273162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/qual[ ]*:/)
273262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2733177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NewId = ++$MAX_ID;
2734177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2735177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase{$Version}{$TypeId} = "$NewId";
2736177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase_R{$Version}{$NewId} = $TypeId;
2737177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info"}{$NewId} = $LibInfo{$Version}{"info"}{$TypeId};
2738177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info_type"}{$NewId} = $LibInfo{$Version}{"info_type"}{$TypeId};
273962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
274062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
274162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = "Typedef";
274262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
274362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
274462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = getTypeType($TypeId);
274562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
274662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2747177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $ScopeId = getTreeAttr_Scpe($TypeDeclId))
2748177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2749177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$ScopeId} eq "function_decl")
2750177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # local code
2751177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2752177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2753177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2754177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Unknown") {
2756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
2757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"}=~/(Func|Method|Field)Ptr/)
2759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
276062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getMemPtrAttr(pointTo($TypeId), $TypeId, $TypeAttr{"Type"});
2761989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(my $TName = $TypeAttr{"Name"})
2762989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
276362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2764989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TName} = $TypeId;
2765989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2766989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2767989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        else {
2768989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return ();
2769989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"} eq "Array")
2772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
277362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
277462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
27750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
27760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2777f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2778f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2779f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2780fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
278162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my %BTAttr = getTypeAttr($BTid))
2782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
278362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $BTAttr{"Name"}) {
278462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
278562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
27860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $NElems = getArraySize($TypeId, $BTAttr{"Name"}))
2787989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
278862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Size = getSize($TypeId)) {
278962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeAttr{"Size"} = $Size/$BYTE_SIZE;
279062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
27910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2792989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[$NElems]".$2;
2793989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2794989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
27950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[$NElems]";
2796989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2798989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
2799989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2800989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version}; # pointer
28010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2802989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[]".$2;
2803989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2804989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
28050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[]";
2806989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
28089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
28090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BTAttr{"Header"})  {
28100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Header"} = $BTAttr{"Header"};
2811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
281262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2813989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2814989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return ();
2817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2818177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/\A(Intrinsic|Union|Struct|Enum|Class|Vector)\Z/)
2819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
282062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
28210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"})
28220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
282362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2825177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $IntrinsicNames{$TypeAttr{"Name"}}
2826177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or getTypeDeclId($TypeAttr{"Tid"}))
28270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # NOTE: register only one int: with built-in decl
28280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
28290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
28300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
28310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
28320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return %TypeAttr;
28330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
28340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
28350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2838177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/TemplateParam|TypeName/)
2839177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2840177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
2841177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2842177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2843177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2844177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
2845177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2846177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2847177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2848177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2849177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2850177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2851177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2852177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2853177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"} eq "SizeOf")
2854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"BaseType"} = getTreeAttr_Type($TypeId);
2856177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
2857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Name"} = "sizeof(".$BTAttr{"Name"}.")";
2858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
2859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2860177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2861177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
2862177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
2864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
2868989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # derived types
286962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
287062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
28710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
28720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2873fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
287462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$BTid})
2875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
287662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $MissedTDid = $MissedTypedef{$Version}{$BTid}{"TDid"})
2877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
287862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($MissedTDid ne $TypeDeclId) {
2879fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeAttr{"BaseType"} = $MissedTypedef{$Version}{$BTid}{"Tid"};
288062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2883fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
28840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $BTAttr{"Name"})
288562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # templates
2886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTAttr{"Type"} eq "Typedef")
2889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relinking typedefs
2890fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %BaseBase = get_Type($BTAttr{"BaseType"}, $Version);
289162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($BTAttr{"Name"} eq $BaseBase{"Name"}) {
2892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TypeAttr{"BaseType"} = $BaseBase{"Tid"};
2893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
28950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTSpec)
2896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer"
28980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BTAttr{"Name"}=~/\([\*]+\)/)
2899989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
29000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"};
2901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Name"}=~s/\(([*]+)\)/($1*)/g;
2902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
29040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"}." ".$BTSpec;
2905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
29080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Name"} = $BTAttr{"Name"};
2909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TypeAttr{"Type"} eq "Typedef")
2911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Name"} = getNameByInfo($TypeDeclId);
291374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
291474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(index($TypeAttr{"Name"}, "tmp_add_type")==0) {
291574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return ();
291674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
291774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2918850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(isAnon($TypeAttr{"Name"}))
2919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # anon typedef to anon type: ._N
2920850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return ();
2921850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
29228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
29238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$TypeDeclId}=~/ artificial /i)
29248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # artificial typedef of "struct X" to "X"
29258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeAttr{"Artificial"} = 1;
29268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
29278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
2928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $NS = getNameSpace($TypeDeclId))
2929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $TypeName = $TypeAttr{"Name"};
2931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NS=~/\A(struct |union |class |)((.+)::|)\Q$TypeName\E\Z/)
2932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # "some_type" is the typedef to "struct some_type" in C++
2933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($3) {
2934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TypeAttr{"Name"} = $3."::".$TypeName;
2935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
2938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"NameSpace"} = $NS;
2940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
2941989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2942989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($TypeAttr{"NameSpace"}=~/\Astd(::|\Z)/
2943989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    and $TypeAttr{"Name"}!~/>(::\w+)+\Z/)
2944989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
29450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($BTAttr{"NameSpace"}
29460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        and $BTAttr{"NameSpace"}=~/\Astd(::|\Z)/ and $BTAttr{"Name"}=~/</)
2947989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        { # types like "std::fpos<__mbstate_t>" are
2948989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # not covered by typedefs in the TU dump
2949989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # so trying to add such typedefs manually
29500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $StdCxxTypedef{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if(length($TypeAttr{"Name"})<=length($BTAttr{"Name"}))
2952989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                            {
29530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/))
2954989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                { # skip "other" in "std" and "type" in "boost"
29550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                    $Typedef_Eq{$Version}{$BTAttr{"Name"}} = $TypeAttr{"Name"};
2956989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                }
2957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
2958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
2959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TypeAttr{"Name"} ne $BTAttr{"Name"} and not $TypeAttr{"Artificial"}
29630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $TypeAttr{"Name"}!~/>(::\w+)+\Z/ and $BTAttr{"Name"}!~/>(::\w+)+\Z/)
2964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
29650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not defined $Typedef_BaseName{$Version}{$TypeAttr{"Name"}})
29660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # typedef int*const TYPEDEF; // first
29670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # int foo(TYPEDEF p); // const is optimized out
29680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Typedef_BaseName{$Version}{$TypeAttr{"Name"}} = $BTAttr{"Name"};
29690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if($BTAttr{"Name"}=~/</)
29700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
29710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/)) {
29720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Typedef_Tr{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
29730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
2974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
2975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeDeclId);
2978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TypeAttr{"Size"})
2980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer") {
2982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version};
2983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($BTAttr{"Size"}) {
29850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Size"} = $BTAttr{"Size"};
2986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2988f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2989f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2990f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
29919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
29920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $TypeAttr{"Header"} and $BTAttr{"Header"})  {
29930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Header"} = $BTAttr{"Header"};
2994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
299562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
29960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"} ne $BTAttr{"Name"})
2997989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # typedef to "class Class"
2998989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko          # should not be registered in TName_Tid
2999989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3000989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3001989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
3002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %TypeAttr;
3004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
300762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeVec($)
300862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
300962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Vector = ();
301062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
301162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
301262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
301362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # string length is N-1 because of the null terminator
301462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Vector{$1} = $2;
301562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
301662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
301762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return \%Vector;
301862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
301962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TemplateParam($$)
3021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $Type_Id) = @_;
302362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type_Id);
302462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $NodeType = $LibInfo{$Version}{"info_type"}{$Type_Id};
302562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $NodeType);
302662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($NodeType eq "integer_cst")
3027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # int (1), unsigned (2u), char ('c' as 99), ...
302862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $CstTid = getTreeAttr_Type($Type_Id);
3029b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my %CstType = getTypeAttr($CstTid); # without recursion
3030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = getNodeIntCst($Type_Id);
3031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $CstSuffix = $ConstantSuffix{$CstType{"Name"}}) {
303262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Num.$CstSuffix);
3033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
303562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("(".$CstType{"Name"}.")".$Num);
3036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
303862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "string_cst") {
303962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getNodeStrCst($Type_Id));
3040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
304162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "tree_vec")
304262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
304362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Vector = getTreeVec($Type_Id);
304462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = ();
304562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P1 (sort {int($a)<=>int($b)} keys(%{$Vector}))
304662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
304762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $P2 (get_TemplateParam($Pos, $Vector->{$P1})) {
304862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@Params, $P2);
304962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
305062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
305162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return @Params;
3052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($NodeType eq "parm_decl")
3054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        (getNameByInfo($Type_Id));
3056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
305962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ParamAttr = getTypeAttr($Type_Id);
3060b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $PName = $ParamAttr{"Name"};
3061b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $PName) {
306262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ();
3063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3064b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($PName=~/\>/)
3065b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        {
3066b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(my $Cover = cover_stdcxx_typedef($PName)) {
3067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PName = $Cover;
3068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Pos>=1 and
30711477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        $PName=~/\A$DEFAULT_STD_PARMS\</)
3072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
3073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Key, typename _Compare = std::less<_Key>
3074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
3075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
3076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
3077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
307862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("\@skip\@");
3079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
308062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($PName);
3081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cover_stdcxx_typedef($)
3085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
3087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)}
3088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # take the shortest typedef
3090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: there may be more than
3091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # one typedefs to the same type
3092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Covers[0];
3093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3094f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Covered = $TypeName;
3095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName=~s/(>)[ ]*(const|volatile|restrict| |\*|\&)\Z/$1/g){};
3096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)} sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3098f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Cover = $Covers[0])
3099f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
3100f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\W|\Z)/$Cover$1/g;
3101f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\w|\Z)/$Cover $1/g;
3102f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
31049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return formatName($Covered, "T");
3105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeIntCst($)
3108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $CstId = $_[0];
311062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CstTypeId = getTreeAttr_Type($CstId);
3111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($EnumMembName_Id{$Version}{$CstId}) {
3112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $EnumMembName_Id{$Version}{$CstId};
3113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif((my $Value = getTreeValue($CstId)) ne "")
3115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3116dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Value eq "0")
3117dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
311862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "false";
3120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "0";
3123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Value eq "1")
3126dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
312762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "true";
3129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "1";
3132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Value;
3136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3138dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeStrCst($)
3142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3143dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3144dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/strg[ ]*: (.+) lngt:[ ]*(\d+)/)
314601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
314701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$_[0]} eq "string_cst")
314801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # string length is N-1 because of the null terminator
314901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2-1);
315001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
315101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            else
315201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # identifier_node
315301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2);
315401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
3155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3157dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
316062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getMemPtrAttr($$$)
3161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # function, method and field pointers
316262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($PtrId, $TypeId, $Type) = @_;
3163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo = $LibInfo{$Version}{"info"}{$PtrId};
3164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr") {
3165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemInfo = $LibInfo{$Version}{"info"}{$TypeId};
3166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo_Type = $LibInfo{$Version}{"info_type"}{$PtrId};
3168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemPtrName = "";
316962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TypeAttr = ("Size"=>$WORD_SIZE{$Version}, "Type"=>$Type, "Tid"=>$TypeId);
3170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "MethodPtr")
3171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # size of "method pointer" may be greater than WORD size
317201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Size = getSize($TypeId))
317301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
317401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $Size/=$BYTE_SIZE;
317501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr{"Size"} = "$Size";
317662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3178f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3180f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Return
3182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr")
3183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
318462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ReturnAttr = getTypeAttr($PtrId);
3185989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($ReturnAttr{"Name"}) {
3186989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3187989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
3188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Return"} = $PtrId;
3189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/retn[ ]*:[ ]*\@(\d+) /)
3193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnTypeId = $1;
319562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %ReturnAttr = getTypeAttr($ReturnTypeId);
319662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $ReturnAttr{"Name"})
319762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
319862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
3199989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
320062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Return"} = $ReturnTypeId;
3202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Class
3205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemInfo=~/(clas|cls)[ ]*:[ ]*@(\d+) /)
3206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Class"} = $2;
320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class = getTypeAttr($TypeAttr{"Class"});
3209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Class{"Name"}) {
3210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (".$Class{"Name"}."\:\:*)";
3211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (*)";
3214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
3217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (*)";
3218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Parameters
3220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FuncPtr"
3221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type eq "MethodPtr")
3222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ParamTypeName = ();
3224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/prms[ ]*:[ ]*@(\d+) /)
3225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3226989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $PTypeInfoId = $1;
322701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my ($Pos, $PPos) = (0, 0);
3228989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($PTypeInfoId)
3229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3230989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my $PTypeInfo = $LibInfo{$Version}{"info"}{$PTypeInfoId};
3231989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($PTypeInfo=~/valu[ ]*:[ ]*@(\d+) /)
3232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
323362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $PTypeId = $1;
323462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %ParamAttr = getTypeAttr($PTypeId);
3235989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if(not $ParamAttr{"Name"})
3236989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    { # templates (template_type_parm), etc.
3237989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        return ();
3238989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3239989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($ParamAttr{"Name"} eq "void") {
3240989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3241989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
324262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Pos!=0 or $Type ne "MethodPtr")
3243989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
324401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TypeAttr{"Param"}{$PPos++}{"type"} = $PTypeId;
3245989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        push(@ParamTypeName, $ParamAttr{"Name"});
3246989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
324762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($PTypeInfoId = getNextElem($PTypeInfoId)) {
324862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Pos+=1;
3249989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3250989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    else {
3251989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3252989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3253989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
3254989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
3255989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    last;
3256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (".join(", ", @ParamTypeName).")";
3260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
32619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($MemPtrName, "T");
3262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
3263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeTypeName($)
3266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
32670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
32680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
32700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "integer_type")
3271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
32720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Name = getNameByInfo($TypeId))
32730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # bit_size_type
32740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Name;
32750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
32760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($Info=~/unsigned/) {
3277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "unsigned int";
3278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "int";
3281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
32834b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        elsif($Info=~/name[ ]*:[ ]*@(\d+) /) {
32840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return getNameByInfo($1);
32850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
32900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFuncPtr($)
3291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
32920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
32930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
32940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
32950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
32960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/unql[ ]*:/ and $Info!~/qual[ ]*:/) {
32970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 0;
32980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $InfoT1 = $LibInfo{$Version}{"info_type"}{$_[0]}
33010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    and my $InfoT2 = $LibInfo{$Version}{"info_type"}{$Ptd})
3302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($InfoT1 eq "pointer_type"
33040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $InfoT2 eq "function_type") {
33050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isMethodPtr($)
33120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
33140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
33150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "record_type"
33180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$Ptd} eq "method_type"
33190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFieldPtr($)
33270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
33300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "offset_type"
33310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
33320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
33340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
33350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
33360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub pointTo($)
33390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
33410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+)/) {
33430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $1;
3344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "";
33470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
33480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
33490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getTypeTypeByTypeId($)
33500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
33510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
33520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $TType = $LibInfo{$Version}{"info_type"}{$TypeId})
33530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
33540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $NType = $NodeType{$TType};
33550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($NType eq "Intrinsic") {
33560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFuncPtr($TypeId)) {
33590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FuncPtr";
33600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isMethodPtr($TypeId)) {
33620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "MethodPtr";
33630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFieldPtr($TypeId)) {
33650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FieldPtr";
33660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
33670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($NType ne "Other") {
33680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
33690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
33710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Unknown";
3372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
337474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %UnQual = (
337574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "r"=>"restrict",
337674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "v"=>"volatile",
337774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "c"=>"const",
337874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "cv"=>"const volatile"
337974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
338074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getQual($)
3382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
3384dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3385dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3386dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($Qual, $To) = ();
3387dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/qual[ ]*:[ ]*(r|c|v|cv) /) {
3388dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Qual = $UnQual{$1};
3389dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3390dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*\@(\d+)/) {
3391dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $To = $1;
3392dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3393dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Qual and $To) {
3394dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return ($Qual, $To);
3395dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ();
3398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualType($)
34010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] eq "const volatile") {
34030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "ConstVolatile";
34040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ucfirst($_[0]);
34060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
340862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeType($)
34090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
341062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
341162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
341262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
34130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # support for old GCC versions
341462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq $TypeDeclId) {
341562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "Typedef";
341662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
34170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
34209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(($Qual or $To) and $TypeDeclId
34219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and (getTypeId($TypeDeclId) ne $TypeId))
34220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
342362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return getQualType($Qual);
34240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
342562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MissedBase_R{$Version}{$TypeId}
342662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and isTypedef($TypeId)) {
34270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Typedef";
34280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual)
34300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
34310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return getQualType($Qual);
34320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info=~/unql[ ]*:[ ]*\@(\d+)/)
34359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # typedef struct { ... } name
34369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeTypedef{$Version}{$TypeId} = $1;
34379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
34389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
34390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeType = getTypeTypeByTypeId($TypeId);
34400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($TypeType eq "Struct")
34410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeDeclId
34430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$TypeDeclId} eq "template_decl") {
34440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "Template";
34450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
34460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $TypeType;
34480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
345062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub isTypedef($)
345162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
3452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0])
345362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3454177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "vector_type")
3455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
3456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return 0;
3457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3460e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(my $TDid = getTypeDeclId($_[0]))
3461e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            {
3462e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(getTypeId($TDid) eq $_[0]
3463e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                and getNameByInfo($TDid))
3464e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                {
3465e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if($Info=~/unql[ ]*:[ ]*\@(\d+) /) {
3466e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                        return $1;
3467e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3468e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
3469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
347062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
347162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
347262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
347362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
347462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
347562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectBaseType($)
3476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
347762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
347862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
347962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add missed typedefs
348062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq getTypeDeclId($TypeId)) {
348162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($TypeId, "");
348262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
34850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $InfoType = $LibInfo{$Version}{"info_type"}{$TypeId};
348662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
348762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB_R = $MissedBase_R{$Version}{$TypeId};
348862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB = $MissedBase{$Version}{$TypeId};
348962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3490dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
34910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(($Qual or $To) and $Info=~/name[ ]*:[ ]*\@(\d+) /
349262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (getTypeId($1) ne $TypeId)
349362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (not $MB_R or getTypeId($1) ne $MB_R))
34940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
349562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getTypeId($1), $Qual);
349662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
349762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($MB)
349862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add base
349962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($MB, "");
3500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
350162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MB_R and my $Bid = isTypedef($TypeId))
3502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # typedefs
350362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($Bid, "");
3504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual or $To)
35060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
350762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($To, $Qual);
3508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "reference_type")
3510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/refd[ ]*:[ ]*@(\d+) /) {
351262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "&");
3513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "array_type")
3516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/elts[ ]*:[ ]*@(\d+) /) {
351862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "");
3519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "pointer_type")
3522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
35230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+) /) {
352462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "*");
3525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return (0, "");
3529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo_All()
3532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "function_decl") {
353662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getSymbolInfo($_);
3537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
3541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
3543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$Version}}))
3544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Map = ();
3546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $ClassId = $SymbolInfo{$Version}{$Sid}{"Class"})
3548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TemplateMap{$Version}{$ClassId})
3550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%{$TemplateMap{$Version}{$ClassId}})) {
3552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Map{$_} = $TemplateMap{$Version}{$ClassId}{$_};
3553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Sid})
3558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$TemplateMap{$Version}{$Sid}})) {
3560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Map{$_} = $TemplateMap{$Version}{$Sid}{$_};
3561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $SymbolInfo{$Version}{$Sid}{"Param"})
3565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$SymbolInfo{$Version}{$Sid}{"Param"}}))
3567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $PTid = $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"};
3569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"} = instType(\%Map, $PTid, $Version);
3570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Return = $SymbolInfo{$Version}{$Sid}{"Return"}) {
3573177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $SymbolInfo{$Version}{$Sid}{"Return"} = instType(\%Map, $Return, $Version);
3574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo_All()
3580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "var_decl") {
358462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getVarInfo($_);
3585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isBuiltIn($) {
3590dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($_[0] and $_[0]=~/\<built\-in\>|\<internal\>|\A\./);
3591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo($)
3594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
359601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $NSid = getTreeAttr_Scpe($InfoId))
3597dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3598dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $NSInfoType = $LibInfo{$Version}{"info_type"}{$NSid};
3599dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($NSInfoType and $NSInfoType eq "function_decl") {
3600dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return;
3601dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
3604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
3605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"})) {
3606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
360962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = getTreeStr(getTreeAttr_Name($InfoId));
3610850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $ShortName) {
3611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3614850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($ShortName=~/\Atmp_add_class_\d+\Z/) {
3615850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3616850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
3617850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3618850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = $ShortName;
3619f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
3620f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
3621f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
3622f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
3623f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
3624f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3625f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
3626f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
36289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
3629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate mangled name
3630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($ShortName, "_Z")==0)
36350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # _ZTS, etc.
3636850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
36370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
36380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(isPrivateData($SymbolInfo{$Version}{$InfoId}{"MnglName"}))
36390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
36400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
36410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
36420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
3643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Data"} = 1;
364462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = getTypeId($InfoId))
36450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
3646177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Rid}
3647177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Rid}{"Name"})
3648177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
36490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
36500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return;
36510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
365262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Rid;
365362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Val = getDataVal($InfoId, $Rid);
36540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Val) {
36550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Value"} = $Val;
36560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    set_Class_And_Namespace($InfoId);
365962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
366062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3661177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
3662177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
3663177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
366462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
366562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
366662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
366762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
366835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
366935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
3670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
367135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3673dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
3674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
3675850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $CheckHeadersOnly)
36785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
36795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Class"})
36805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        {
36815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
36825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
36835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
36845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if(link_symbol($ShortName, $Version, "-Deps"))
36855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                { # "const" global data is mangled as _ZL... in the TU dump
36865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                  # but not mangled when compiling a C shared library
36875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
36885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
36895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
36905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
36915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
3692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
3693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for some symbols (_ZTI) the short name is the mangled name
36969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($ShortName, "_Z")==0) {
3697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
3702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"MnglName"} = linkSymbol($InfoId);
3703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
3705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
3707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # link MS C++ symbols from library with GCC symbols from headers
3708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
3709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}) {
3713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3715850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
3717850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
3718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
3719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
3720850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return;
3721850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
372362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
372462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
372562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
372662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
372762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
372862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
372962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
373062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setFuncAccess($InfoId);
37339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_ZTV")==0) {
3734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
3735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShortName=~/\A(_Z|\?)/) {
3737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"ShortName"});
3738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
373974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
374074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
374174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
374274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
3743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3745850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub isConstType($$)
3746850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
3747850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
374862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Base = get_Type($TypeId, $LibVersion);
3749850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    while(defined $Base{"Type"} and $Base{"Type"} eq "Typedef") {
3750f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        %Base = get_OneStep_BaseType($Base{"Tid"}, $TypeInfo{$LibVersion});
3751850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3752850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Base{"Type"} eq "Const");
3753850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
3754850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTrivialName($$)
3756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeInfoId, $TypeId) = @_;
3758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeAttr = ();
3759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"} = getNameByInfo($TypeInfoId);
3760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = getTreeTypeName($TypeId);
3762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3763dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
376462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"}=~s/<(.+)\Z//g; # GCC 3.4.4 add template params to the name
37661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
37671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
37681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $NameSpaceId = $TypeId;
376901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        while(my $NSId = getTreeAttr_Scpe(getTypeDeclId($NameSpaceId)))
37701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # searching for a first not anon scope
37711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NSId eq $NameSpaceId) {
37721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                last;
37731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
37741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
37751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
37761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace(getTypeDeclId($TypeId));
37771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $TypeAttr{"NameSpace"}
37782956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko                or not isAnon($TypeAttr{"NameSpace"})) {
37791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    last;
37801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
37811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3782177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $NameSpaceId = $NSId;
37831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
37841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
37851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
37861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
378701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $NameSpaceId = getTreeAttr_Scpe($TypeInfoId))
37881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
37891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NameSpaceId ne $TypeId) {
37901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace($TypeInfoId);
37911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
37942956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko    if($TypeAttr{"NameSpace"} and not isAnon($TypeAttr{"Name"})) {
3795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
37979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
3798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
37991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # anon-struct-header.h-line
3800dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $TypeAttr{"Name"} = "anon-".lc($TypeAttr{"Type"})."-";
3801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} .= $TypeAttr{"Header"}."-".$TypeAttr{"Line"};
3802dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($TypeAttr{"NameSpace"}) {
3803dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3804dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3806b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId}
3807b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    and getTypeDeclId($TypeId) eq $TypeInfoId)
3808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3809b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type")) {
3810b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."< ".join(", ", @TParams)." >", "T");
3811b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3812b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
3813b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."<...>", "T");
3814b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"});
3817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
381962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTrivialTypeAttr($)
3820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
382162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
382262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeInfoId = getTypeDeclId($_[0]);
3823850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %TypeAttr = ();
3825177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3826850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TemplateDecl{$Version}{$TypeId})
3827850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # template_decl
3828177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Template"} = 1;
382962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
3830850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTypeAccess($TypeId, \%TypeAttr);
3832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
3833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isBuiltIn($TypeAttr{"Header"}))
3834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Header"});
3836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Line"});
3837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38382489ef88760861175102e4508089608391beead3Andrey Ponomarenko
383962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"}) = getTrivialName($TypeInfoId, $TypeId);
3841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
3843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"NameSpace"}) {
3845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"NameSpace"});
3846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3847177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
38482489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Intrinsic")
38492489ef88760861175102e4508089608391beead3Andrey Ponomarenko    {
38502489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(defined $TypeAttr{"Header"})
38512489ef88760861175102e4508089608391beead3Andrey Ponomarenko        {
38522489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if($TypeAttr{"Header"}=~/\Adump[1-2]\.[ih]\Z/)
38532489ef88760861175102e4508089608391beead3Andrey Ponomarenko            { # support for SUSE 11.2
38542489ef88760861175102e4508089608391beead3Andrey Ponomarenko              # integer_type has srcp dump{1-2}.i
38552489ef88760861175102e4508089608391beead3Andrey Ponomarenko                delete($TypeAttr{"Header"});
38562489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
38572489ef88760861175102e4508089608391beead3Andrey Ponomarenko        }
38582489ef88760861175102e4508089608391beead3Andrey Ponomarenko    }
38592489ef88760861175102e4508089608391beead3Andrey Ponomarenko
3860177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = undef;
3861177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
386262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId})
38631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
3864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $Tmpl = $BasicTemplate{$Version}{$TypeId};
3865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
386662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type"))
38671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
3868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (0 .. $#TParams)
3869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Val = $TParams[$Pos];
3871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"TParam"}{$Pos}{"name"} = $Val;
3872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3873177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not defined $TypeAttr{"Template"})
3874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3875177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my %Base = get_BaseType($TemplateInstance{$Version}{"Type"}{$TypeId}{$Pos}, $Version);
3876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Base{"Type"} eq "TemplateParam"
3878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or defined $Base{"Template"}) {
3879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeAttr{"Template"} = 1;
3880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Tmpl)
3884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
3886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = $Val;
3888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($Val eq $Arg) {
3890177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TypeAttr{"Template"} = 1;
3891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3893177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
3897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
3899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Pos>$#TParams)
3901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
3903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = "";
3904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ADD_TMPL_INSTANCES)
3910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3911e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if($Tmpl)
3912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3913e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(my $MainInst = getTreeAttr_Type($Tmpl))
3914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3915e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Flds($TypeId))
3916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
3917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Flds = getTreeAttr_Flds($MainInst)) {
3918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " flds: \@$Flds ";
3919177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3920e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3921e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Binf($TypeId))
3922e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    {
3923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Binf = getTreeAttr_Binf($MainInst)) {
3924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " binf: \@$Binf ";
3925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
3926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
39281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
39291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
39301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
3931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $StaticFields = setTypeMemb($TypeId, \%TypeAttr);
3933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
393401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Size = getSize($TypeId))
393501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
393601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Size = $Size/$BYTE_SIZE;
393701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeAttr{"Size"} = "$Size";
3938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
3940177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ExtraDump)
3942177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3943177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $TypeAttr{"Memb"}
3944177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not $Tmpl)
3945177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # declaration only
3946177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"Forward"} = 1;
3947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
39499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
395074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
395274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    and ($StaticFields or detect_lang($TypeId)))
3953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Type"} = "Class";
3955850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $TypeAttr{"Copied"} = 1; # default, will be changed in getSymbolInfo()
3956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
3958850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    or $TypeAttr{"Type"} eq "Class")
3959850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
396062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Skip = setBaseClasses($TypeId, \%TypeAttr);
3961850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Skip) {
3962850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return ();
3963850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3965f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3966f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3967f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setSpec($TypeId, \%TypeAttr);
396974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
397074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeAttr{"Type"}=~/\A(Struct|Union|Enum)\Z/)
397174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
397274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $TypedefToAnon{$TypeId}
3973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        and not defined $TemplateInstance{$Version}{"Type"}{$TypeId})
397474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
397574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not isAnon($TypeAttr{"Name"})) {
397674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeAttr{"Name"} = lc($TypeAttr{"Type"})." ".$TypeAttr{"Name"};
397774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
397874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
397974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
398074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
3982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VTable = $ClassVTable_Content{$Version}{$TypeAttr{"Name"}})
3983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Entries = split(/\n/, $VTable);
3985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $#Entries)
3986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Entry = $Entries[$_];
3988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry=~/\A(\d+)\s+(.+)\Z/) {
3989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"VTable"}{$1} = simplifyVTable($2);
3990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
399382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
399482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Enum")
399582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
399682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if(not $TypeAttr{"NameSpace"})
399782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
399882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            foreach my $Pos (keys(%{$TypeAttr{"Memb"}}))
399982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            {
400082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                my $MName = $TypeAttr{"Memb"}{$Pos}{"name"};
40018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $MVal = $TypeAttr{"Memb"}{$Pos}{"value"};
400282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                $EnumConstants{$Version}{$MName} = {
40038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    "Value"=>$MVal,
400482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                    "Header"=>$TypeAttr{"Header"}
400582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                };
40068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(isAnon($TypeAttr{"Name"}))
40078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
4008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($ExtraDump
4009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or is_target_header($TypeAttr{"Header"}, $Version))
4010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$Constants{$Version}{$MName}} = (
4012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Value" => $MVal,
4013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Header" => $TypeAttr{"Header"}
4014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        );
4015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
40168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
401782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            }
401882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
401982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
402074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
40214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
40224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(defined $TypedefToAnon{$TypeId}) {
40234b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr{"AnonTypedef"} = 1;
40244b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
40254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
402682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
4027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
4028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub simplifyVTable($)
4031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
4032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Content = $_[0];
4033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Content=~s/ \[with (.+)]//)
4034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # std::basic_streambuf<_CharT, _Traits>::imbue [with _CharT = char, _Traits = std::char_traits<char>]
4035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my @Elems = separate_Params($1, 0, 0))
4036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Elem (@Elems)
4038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Elem=~/\A(.+?)\s*=\s*(.+?)\Z/)
4040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my ($Arg, $Val) = ($1, $2);
4042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $DEFAULT_STD_ARGS{$Arg}) {
4044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/,\s*$Arg\b//g;
4045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    else {
4047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/\b$Arg\b/$Val/g;
4048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
4053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Content;
4055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
4056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lang($)
4058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
4060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
406162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
40621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4 fncs-node points to only non-artificial methods
4063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Info=~/(fncs)[ ]*:[ ]*@(\d+) /);
4064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
40661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
406762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Fncs = getTreeAttr_Fncs($TypeId);
4068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Fncs)
4069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
407062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info"}{$Fncs}!~/artificial/) {
4071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
4072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
407362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Fncs = getTreeAttr_Chan($Fncs);
4074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
4077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setSpec($$)
4080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Info=~/\s+spec\s+/) {
4084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Spec"} = 1;
4085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
408862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub setBaseClasses($$)
4089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
409062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4092177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Binf = getTreeAttr_Binf($TypeId))
4093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4094177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Info = $LibInfo{$Version}{"info"}{$Binf};
4095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
4096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Info=~s/(pub|public|prot|protected|priv|private|)[ ]+binf[ ]*:[ ]*@(\d+) //)
4097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Access, $BInfoId) = ($1, $2);
4099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ClassId = getBinfClassId($BInfoId);
4100b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4101b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            if($ClassId==$TypeId)
4102b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            { # class A<N>:public A<N-1>
4103b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko                next;
4104b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            }
4105b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4106850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $CType = $LibInfo{$Version}{"info_type"}{$ClassId};
4107850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CType or $CType eq "template_type_parm"
4108850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $CType eq "typename_type")
4109850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # skip
4110177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                # return 1;
4111850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
4112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseInfo = $LibInfo{$Version}{"info"}{$BInfoId};
41134b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($Access=~/prot/) {
4114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "protected";
4115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
41164b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            elsif($Access=~/priv/) {
4117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "private";
4118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
411901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr->{"Base"}{$ClassId}{"pos"} = "$Pos";
4120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseInfo=~/virt/)
41211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual base
4122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"virtual"} = 1;
4123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Class_SubClasses{$Version}{$ClassId}{$TypeId}=1;
41254b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $Pos += 1;
4126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4128850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
4129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getBinfClassId($)
4132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$_[0]};
4134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Info=~/type[ ]*:[ ]*@(\d+) /;
4135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $1;
4136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangledFormat($$)
4139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion) = @_;
4141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name = uncover_typedefs($Name, $LibVersion);
4142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Name=~s/([^\w>*])(const|volatile)(,|>|\Z)/$1$3/g){};
4143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\(\w+\)(\d)/$1/;
4144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
4145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub modelUnmangled($$)
4148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $Compiler) = @_;
4150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId}) {
4151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId};
4152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $PureSignature = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
4154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = "~".$PureSignature;
4156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Data"})
4158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@Params, @ParamTypes) = ();
4160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$Version}{$InfoId}{"Param"}
4161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$Version}{$InfoId}{"Param"}});
4163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"type"};
4167f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $PName = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"name"};
4168f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PType = get_PureType($PId, $TypeInfo{$Version});
4169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PTName = unmangledFormat($PType{"Name"}, $Version);
4170f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
4171f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($PName eq "this"
4172f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method")
4173f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
4174f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
4175f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
4176f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
417762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $PTName=~s/\b(restrict|register)\b//g;
4178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC") {
417962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $PTName=~s/\blong long\b/__int64/;
4180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @ParamTypes = (@ParamTypes, $PTName);
4182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@ParamTypes) {
4184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature .= "(".join(", ", @ParamTypes).")";
4185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC")
4189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
4190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "(void)";
4191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # GCC
4194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "()";
4195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = delete_keywords($PureSignature);
4198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
4200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
420162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ClassName = unmangledFormat($TypeInfo{$Version}{$ClassId}{"Name"}, $Version);
4202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $ClassName."::".$PureSignature;
4203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $NS = $SymbolInfo{$Version}{$InfoId}{"NameSpace"}) {
4205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $NS."::".$PureSignature;
4206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Const"}) {
4208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " const";
4209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Volatile"}) {
4211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " volatile";
4212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShowReturn = 0;
4214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "MSVC"
4215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Data"})
4216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
421962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(defined $TemplateInstance{$Version}{"Func"}{$InfoId}
422062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and keys(%{$TemplateInstance{$Version}{"Func"}{$InfoId}}))
4221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowReturn)
4225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled names for template function specializations include return value
4226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ReturnId = $SymbolInfo{$Version}{$InfoId}{"Return"})
4227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4228f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %RType = get_PureType($ReturnId, $TypeInfo{$Version});
4229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnName = unmangledFormat($RType{"Name"}, $Version);
4230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature = $ReturnName." ".$PureSignature;
4231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
42339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId} = formatName($PureSignature, "S"));
4234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_symbol($$$)
4237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # mangling for simple methods
4238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # see gcc-4.6.0/gcc/cp/mangle.c
4239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Compiler) = @_;
4240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler}) {
4241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler};
4242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = "";
4244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "GCC") {
42451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_GCC($InfoId, $LibVersion);
4246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Compiler eq "MSVC") {
42481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_MSVC($InfoId, $LibVersion);
4249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler} = $Mangled);
4251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_MSVC($$)
4254b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko{ # TODO
4255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
42591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_GCC($$)
4260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # see gcc-4.6.0/gcc/cp/mangle.c
4261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $ClassId, $NameSpace) = ("_Z", 0, "");
42631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
4264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Repl = ();# SN_ replacements
4265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
4266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledClass = mangle_param($ClassId, $LibVersion, \%Repl);
4268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledClass!~/\AN/) {
4269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass = "N".$MangledClass;
4270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/E\Z//;
4273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Volatile"}) {
4275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NV/;
4276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Const"}) {
4278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NK/;
4279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledClass;
4281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($NameSpace = $SymbolInfo{$LibVersion}{$InfoId}{"NameSpace"})
4283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled by name due to the absence of structured info
4284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = mangle_ns($NameSpace, $LibVersion, \%Repl);
4285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNS!~/\AN/) {
4286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS = "N".$MangledNS;
4287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS=~s/E\Z//;
4290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledNS;
4292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
429307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($SymbolInfo{$LibVersion}{$InfoId}{"ShortName"});
42941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my @TParams = ();
429535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if(my @TPos = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}}))
42961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # parsing mode
429735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        foreach (@TPos) {
429835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            push(@TParams, $SymbolInfo{$LibVersion}{$InfoId}{"TParam"}{$_}{"name"});
429935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
43001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
43011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    elsif($TmplParams)
43021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # remangling mode
43031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko      # support for old ABI dumps
430407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @TParams = separate_Params($TmplParams, 0, 0);
4305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"}) {
4307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "C1";
4308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "D0";
4311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ShortName)
4313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
43141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
43151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
43161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
4317850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and isConstType($Return, $LibVersion))
43181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # "const" global data is mangled as _ZL...
43191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Mangled .= "L";
43201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
43211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
4322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShortName=~/\Aoperator(\W.*)\Z/)
4323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Op = $1;
4325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Op=~s/\A[ ]+//g;
4326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $OpMngl = $OperatorMangling{$Op}) {
4327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= $OpMngl;
4328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else { # conversion operator
4330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= "cv".mangle_param(getTypeIdByName($Op, $LibVersion), $LibVersion, \%Repl);
4331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= length($ShortName).$ShortName;
4335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
43391477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko            foreach my $TParam (@TParams) {
4340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, \%Repl);
4341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ClassId and @TParams) {
4345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($ShortName, \%Repl, 0);
4346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId or $NameSpace) {
4349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4351850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(@TParams)
4352850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
43531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Return) {
4354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($Return, $LibVersion, \%Repl);
4355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
4358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = ();
4360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
4361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
4363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamType_Id = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$ParamPos}{"type"};
4367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($ParamType_Id, $LibVersion, \%Repl);
4368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = correct_incharge($InfoId, $LibVersion, $Mangled);
4374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = write_stdcxx_substitution($Mangled);
4375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mangled eq "_Z") {
4376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub correct_incharge($$$)
4382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Mangled) = @_;
4384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"})
4385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4387f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/C1([EI])/C2$1/;
4388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
4391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4393f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D0([EI])/D1$1/;
4394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4396f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D1([EI])/D2$1/;
4397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
440207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub template_Base($)
4403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # NOTE: std::_Vector_base<mysqlpp::mysql_type_info>::_Vector_impl
44041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko  # NOTE: operators: >>, <<
4405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
44061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Name!~/>\Z/ or $Name!~/</) {
4407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Name;
4408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TParams = $Name;
44101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($TParams, "<"))
44111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # search for the last <T>
4412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TParams = substr($TParams, $CPos);
4413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
44141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($TParams=~s/\A<(.+)>\Z/$1/) {
44151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Name=~s/<\Q$TParams\E>\Z//;
44161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
44171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    else
44181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # error
44191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TParams = "";
44201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $TParams);
4422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_ns($)
4425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
4427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @NS = ();
44281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($Name, ":"))
4429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@NS, substr($Name, 0, $CPos));
4431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name = substr($Name, $CPos);
4432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name=~s/\A:://;
4433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (join("::", @NS), $Name);
4435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_ns($$$)
4438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion, $Repl) = @_;
4440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Tid = $TName_Tid{$LibVersion}{$Name})
4441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Mangled = mangle_param($Tid, $LibVersion, $Repl);
4443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled=~s/\AN(.+)E\Z/$1/;
4444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Mangled;
4445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($MangledNS, $SubNS) = ("", "");
4450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($SubNS, $Name) = get_sub_ns($Name);
4451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($Name).$Name;
4455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        add_substitution($MangledNS, $Repl, 0);
4456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $MangledNS;
4457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_param($$$)
4461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($PTid, $LibVersion, $Repl) = @_;
4463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MPrefix, $Mangled) = ("", "");
4464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %ReplCopy = %{$Repl};
446562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType = get_BaseType($PTid, $LibVersion);
4466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $BaseType_Name = $BaseType{"Name"};
446774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $BaseType_Name=~s/\A(struct|union|enum) //g;
4468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $BaseType_Name) {
4469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
447107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($BaseType_Name);
447262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Suffix = get_BaseTypeQual($PTid, $LibVersion);
4473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~s/\s*(const|volatile|restrict)\Z//g){};
4474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~/(&|\*|const)\Z/)
4475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*&\Z//) {
4477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "R";
4478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*\*\Z//) {
4480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "P";
4481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*const\Z//)
4483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MPrefix=~/R|P/
4485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $Suffix=~/&|\*/) {
4486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MPrefix .= "K";
4487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*volatile\Z//) {
4490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "V";
4491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($Suffix=~s/[ ]*restrict\Z//) {
4493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #$MPrefix .= "r";
4494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
4495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Token = $IntrinsicMangling{$BaseType_Name}) {
4497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $Token;
4498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(Class|Struct|Union|Enum)/)
4500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
45011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my @TParams = ();
450235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if(my @TPos = keys(%{$BaseType{"TParam"}}))
45031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # parsing mode
450435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            foreach (@TPos) {
450535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                push(@TParams, $BaseType{"TParam"}{$_}{"name"});
450635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            }
45071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
45081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        elsif($TmplParams)
45091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # remangling mode
45101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # support for old ABI dumps
451107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            @TParams = separate_Params($TmplParams, 0, 0);
4512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = "";
4514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($SubNS, $SName) = get_sub_ns($ShortName);
4515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($SName).$SName;
4519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams) {
4520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($MangledNS, $Repl, 0);
4521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "N".$MangledNS;
4523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
4526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $TParam (@TParams) {
4527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, $Repl);
4528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(FuncPtr|MethodPtr)/)
4534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($BaseType{"Type"} eq "MethodPtr") {
4536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl)."F";
4537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "PF";
4540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = keys(%{$BaseType{"Param"}});
4543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (sort {int($a)<=>int($b)} @Params) {
4544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($BaseType{"Param"}{$Num}{"type"}, $LibVersion, $Repl);
4545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"} eq "FieldPtr")
4552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl);
4554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = $MPrefix.$Mangled;# add prefix (RPK)
4557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Optimized = write_substitution($Mangled, \%ReplCopy))
4558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Mangled eq $Optimized)
4560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ShortName!~/::/)
4562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # remove "N ... E"
4563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MPrefix) {
4564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\A($MPrefix)N(.+)E\Z/$1$2/g;
4565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
4567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\AN(.+)E\Z/$1/g;
4568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled = $Optimized;
4573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    add_substitution($Mangled, $Repl, 1);
4576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_template_param($$$)
4580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # types + literals
4581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TParam, $LibVersion, $Repl) = @_;
4582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $TPTid = $TName_Tid{$LibVersion}{$TParam}) {
4583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return mangle_param($TPTid, $LibVersion, $Repl);
4584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A(\d+)(\w+)\Z/)
4586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<1u>::method(...)
4587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$ConstantSuffixR{$2}}.$1."E";
4588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A\(([\w ]+)\)(\d+)\Z/)
4590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<(signed char)1>::method(...)
4591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$1}.$2."E";
4592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "true")
4594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb1E";
4596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "false")
4598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb0E";
4600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else { # internal error
4602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return length($TParam).$TParam;
4603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub add_substitution($$$)
4607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Value, $Repl, $Rec) = @_;
4609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Rec)
4610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # subtypes
4611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Subs = ($Value);
4612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Value=~s/\A(R|P|K)//) {
4613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Subs, $Value);
4614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (reverse(@Subs)) {
4616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($_, $Repl, 0);
4617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($Value=~/\AS(\d*)_\Z/);
4621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Value=~s/\AN(.+)E\Z/$1/g;
4622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(defined $Repl->{$Value});
4623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($Value)<=1);
4624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($StdcxxMangling{$Value});
4625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check for duplicates
4626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Base = $Value;
4627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Replace\E/$Type/;
4632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $OldNum = $Repl->{$Base})
4634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $OldNum;
4636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Repls = sort {$b<=>$a} values(%{$Repl});
4639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Repls) {
4640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $Repls[0]+1;
4641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
4643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = -1;
4644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # register duplicates
4646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # upward
4647dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Base = $Value;
4648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Base eq $Type);
4651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Type\E/$Replace/;
4654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Base} = $Repl->{$Value};
4655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub macro_mangle($)
4659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Num = $_[0];
4661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Num==-1) {
4662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S_";
4663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Code = "";
4667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num<10)
4668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S0_, S1_, S2_, ...
4669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num;
4670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Num>=10 and $Num<=35)
4672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SA_, SB_, SC_, ...
4673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = chr(55+$Num);
4674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S10_, S11_, S12_
4677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num-26; # 26 is length of english alphabet
4678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S".$Code."_";
4680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_stdcxx_substitution($)
4684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = $_[0];
4686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdcxxMangling{$Mangled}) {
4687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $StdcxxMangling{$Mangled};
4688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%StdcxxMangling);
4692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = $StdcxxMangling{$MangledType};
4696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #if($Mangled!~/$Replace/) {
4697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #}
4700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_substitution($$)
4706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $Repl) = @_;
4708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Repl->{$Mangled}
4709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $MnglNum = $Repl->{$Mangled}) {
4710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled = macro_mangle($MnglNum);
4711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%{$Repl});
4715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #@Repls = sort {$Repl->{$a}<=>$Repl->{$b}} @Repls;
4716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # FIXME: how to apply replacements? by num or by pos
4717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = macro_mangle($Repl->{$MangledType});
4721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mangled!~/$Replace/) {
4722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub delete_keywords($)
4731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
473362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeName=~s/\b(enum|struct|union|class) //g;
4734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TypeName;
4735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub uncover_typedefs($$)
4738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
4740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName);
4741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName}) {
4742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName};
4743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
47449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($TypeName_New, $TypeName_Pre) = (formatName($TypeName, "T"), "");
4745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName_New ne $TypeName_Pre)
4746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeName_Pre = $TypeName_New;
4748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeName_Copy = $TypeName_New;
4749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Words = ();
475062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($TypeName_Copy=~s/\b([a-z_]([\w:]*\w|))\b//io)
4751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
475262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Intrinsic_Keywords{$1}) {
475362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Words{$1} = 1;
475462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
4755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Word (keys(%Words))
4757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseType_Name = $Typedef_BaseName{$LibVersion}{$Word};
4759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $BaseType_Name);
476062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if($TypeName_New=~/\b(struct|union|enum)\s\Q$Word\E\b/);
4761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseType_Name=~/\([\*]+\)/)
4762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # FuncPtr
4763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TypeName_New=~/\Q$Word\E(.*)\Z/)
4764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
4765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Type_Suffix = $1;
4766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeName_New = $BaseType_Name;
4767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TypeName_New=~s/\(([\*]+)\)/($1 $Type_Suffix)/) {
47689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $TypeName_New = formatName($TypeName_New, "T");
4769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
4770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
477462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeName_New=~s/\b\Q$Word\E\b/$BaseType_Name/g) {
47759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $TypeName_New = formatName($TypeName_New, "T");
4776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"uncover_typedefs"}{$LibVersion}{$TypeName} = $TypeName_New);
4781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInternal($)
4784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4785989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
4786989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
4787989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /)
4788989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
4789989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/\*[ ]*INTERNAL[ ]*\*/)
4790989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # _ZN7mysqlpp8DateTimeC1ERKS0_ *INTERNAL*
4791989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return 1;
4792989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
4793989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
4794989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
4795989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
4796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
47980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getDataVal($$)
47990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/init[ ]*:[ ]*@(\d+) /)
48040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $LibInfo{$Version}{"info_type"}{$1}
48060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $LibInfo{$Version}{"info_type"}{$1} eq "nop_expr")
48078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
48088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $Nop = getTreeAttr_Op($1))
48090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
48108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(defined $LibInfo{$Version}{"info_type"}{$Nop}
48118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $LibInfo{$Version}{"info_type"}{$Nop} eq "addr_expr")
48120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
48138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(my $Addr = getTreeAttr_Op($1)) {
48148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return getInitVal($Addr, $TypeId);
48150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
48160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
48170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            else {
48200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getInitVal($1, $TypeId);
48210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
48270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getInitVal($$)
48280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
48290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
48300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
48310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
48320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$InfoId})
48330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
48340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($InfoType eq "integer_cst")
48350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
48360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Val = getNodeIntCst($InfoId);
483762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeId and $TypeInfo{$Version}{$TypeId}{"Name"}=~/\Achar(| const)\Z/)
48380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # characters
48390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Val = chr($Val);
48400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
48410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Val;
48420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
48430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($InfoType eq "string_cst") {
48440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getNodeStrCst($InfoId);
48450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
484601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($InfoType eq "var_decl")
484701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
484801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Name = getNodeStrCst(getTreeAttr_Mngl($InfoId))) {
484901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    return $Name;
485001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
485101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
48520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
48530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
48540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
48550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
48560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
4857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub set_Class_And_Namespace($)
4858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4860989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
4861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4862989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /)
4863dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
4864989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $NSInfoId = $1;
4865989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
4866989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
4867989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($InfoType eq "namespace_decl") {
4868989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"NameSpace"} = getNameSpace($InfoId);
4869989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4870989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($InfoType eq "record_type") {
4871989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Class"} = $NSInfoId;
4872989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
4873dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
4874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Class"}
4877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"NameSpace"})
4878fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
4879570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($COMMON_LANGUAGE{$Version} ne "C++")
4880fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # skip
4881fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
4882570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
4883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4884fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
4885fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
4886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub debugMangling($)
4889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
4891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Mangled = ();
4892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
4893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Mngl = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
4895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mngl=~/\A(_Z|\?)/) {
4897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled{$Mngl}=$InfoId;
4898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%Mangled), $LibVersion);
4902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Mngl (keys(%Mangled))
4903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4904850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U1 = modelUnmangled($Mangled{$Mngl}, "GCC");
4905850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U2 = $tr_name{$Mngl};
4906850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($U1 ne $U2) {
4907850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            printMsg("INFO", "INCORRECT MANGLING:\n  $Mngl\n  $U1\n  $U2\n");
4908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub linkSymbol($)
4913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # link symbols from shared libraries
4914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # with the symbols from header files
4915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
4916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to mangle symbol
491762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if((not check_gcc($GCC_PATH, "4") and $SymbolInfo{$Version}{$InfoId}{"Class"})
4918f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or (check_gcc($GCC_PATH, "4") and not $SymbolInfo{$Version}{$InfoId}{"Class"})
4919f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or $EMERGENCY_MODE_48)
4920f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # GCC 3.x doesn't mangle class methods names in the TU dump (only functions and global data)
4921f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.x doesn't mangle C++ functions in the TU dump (only class methods) except extern "C" functions
4922f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.8 doesn't mangle anything
49231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CheckHeadersOnly)
4924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name_gcc{modelUnmangled($InfoId, "GCC")}) {
4926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return correct_incharge($InfoId, $Version, $Mangled);
4927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
49291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($CheckHeadersOnly
4930f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or not $BinaryOnly
4931f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or $EMERGENCY_MODE_48)
49321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # 1. --headers-only mode
49331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # 2. not mangled src-only symbols
49341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Mangled = mangle_symbol($InfoId, $Version, "GCC")) {
49351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return $Mangled;
49361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
49371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
4938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setLanguage($$)
4943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Lang) = @_;
4945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $UserLang) {
4946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{$LibVersion} = $Lang;
4947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo($)
4951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
49521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
4953989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isInternal($InfoId)) {
4954989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return;
4955989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
49561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
49571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
4958a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"}))
4959a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncAccess($InfoId);
49641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncKind($InfoId);
4965a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"PseudoTemplate"})
4966a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
49671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
4968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
497074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
49711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Type"} = getFuncType($InfoId);
4972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Return = getFuncReturn($InfoId))
497362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
4974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Return}
4975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Return}{"Name"})
4976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
497762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
497862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
497962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
4980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Return;
498162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
498262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
498362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
498462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
498562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
498662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
498762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
498862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
498962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
4990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Return"}) {
49921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
4993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4994a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Orig = getFuncOrig($InfoId);
4995a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getFuncShortName($Orig);
499674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "\._")!=-1)
499774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
499874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
499974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return;
500074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
500174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
500274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "tmp_add_func")==0)
5003a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
50041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5007a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
5008a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Func"}{$Orig})
5009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Tmpl = $BasicTemplate{$Version}{$InfoId};
5011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5012a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my @TParams = getTParams($Orig, "Func");
5013a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(not @TParams)
5014a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
50151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (0 .. $#TParams)
5019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Val = $TParams[$Pos];
5021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"TParam"}{$Pos}{"name"} = $Val;
5022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
5024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
5026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = $Val;
5028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Tmpl)
5033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
5035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Pos>$#TParams)
5037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
5039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = "";
5040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
50421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
50441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\Aoperator\W+\Z/)
50451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # operator<< <T>, operator>> <T>
50461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= " ";
50471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5048b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(@TParams) {
5049b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<".join(", ", @TParams).">";
5050b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
5051b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
5052b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<...>";
5053b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
50549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} = formatName($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "S");
5055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
5057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC 3.4
50581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5060f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
5061f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
5062f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
5063f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
5064f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
5065f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
5066f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
5067f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
5068f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # NOTE: mangling of some symbols may change depending on GCC version
5069f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.6: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2IT_EERKS_IT_E
5070f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.7: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2ERKS1_
5071f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
5072989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
50731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
50749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
5075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
50761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
50791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Destructor"})
5080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # destructors have an empty parameter list
50811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Skip = setFuncParams($InfoId);
508207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Skip)
508307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
50841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ artificial /i) {
5089fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Artificial"} = 1;
5090fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5091fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5092fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(set_Class_And_Namespace($InfoId))
5093fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5094fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5095fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return;
5096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5097fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
509862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
509962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5100177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
5101177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
5102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
510362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
510462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
510562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
510662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
510735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
510835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
51091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
511035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5112dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
5113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
51141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
5117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # correct mangled & short names
51181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # C++ or --headers-only mode
51191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\A__(comp|base|deleting)_(c|d)tor\Z/)
5120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old GCC versions: reconstruct real names for constructors and destructors
51211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getNameByInfo(getTypeDeclId($SymbolInfo{$Version}{$InfoId}{"Class"}));
51221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
51241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
51261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(my $Mangled = linkSymbol($InfoId)) {
51271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
5128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
5131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # link MS C++ symbols from library with GCC symbols from headers
5132dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Mangled1 = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
5133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # exported symbols
5134dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled1;
5135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5136dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(my $Mangled2 = mangle_symbol($InfoId, $Version, "MSVC"))
5137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual symbols
5138dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled2;
5139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5142fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
5143fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # not mangled in C
5144fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5145fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
51468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $CheckHeadersOnly
51478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function"
51488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and not $SymbolInfo{$Version}{$InfoId}{"Class"})
51498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
51508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Incorrect = 0;
51518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
51528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
51538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")==0
51558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
51568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # mangled in the TU dump, but not mangled in the library
51578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
51618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SymbolInfo{$Version}{$InfoId}{"Lang"} ne "C")
51638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # all C++ functions are not mangled in the TU dump
51648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
51658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Incorrect)
51688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
51698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(link_symbol($SymbolInfo{$Version}{$InfoId}{"ShortName"}, $Version, "-Deps")) {
51708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
51718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
51728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
51738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
51741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # can't detect symbol name
51761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5179989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Constructor"}
5180a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    and my $Spec = getVirtSpec($Orig))
5181989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # identify virtual and pure virtual functions
5182989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: constructors cannot be virtual
5183989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: in GCC 4.7 D1 destructors have no virtual spec
5184989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # in the TU dump, so taking it from the original symbol
5185989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not ($SymbolInfo{$Version}{$InfoId}{"Destructor"}
5186989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        and $SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/D2E/))
5187989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # NOTE: D2 destructors are not present in a v-table
5188989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{$Spec} = 1;
5189989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isInline($InfoId)) {
51921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"InLine"} = 1;
5193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
519482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if(hasThrow($InfoId)) {
5195e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Throw"} = 1;
5196e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
51971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
51981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
5199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"InLine"}
5201b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Artificial"})
5202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # inline or auto-generated constructor
520362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$Version}{$ClassId}{"Copied"});
5204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
5208570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $ExtraDump)
5209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
5210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
5211570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # non-target symbols
5212570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5213570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return;
5214570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
5215850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
5216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method"
52181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Constructor"}
52191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}
52201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Class"})
5221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"}!~/\A(_Z|\?)/)
52239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
52241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
5229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # one instance for one mangled name only
52321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
52361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}} = 1;
5237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
52401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
52411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/
52441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Class"})
5245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function")
5247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # static methods
52481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncLink($InfoId) eq "Static") {
52521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5254dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/)
5255dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5256dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $Unmangled = $tr_name{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5257dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
52589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Unmangled=~/\.\_\d/)
52599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
5260dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5261dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return;
5262dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5263dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5265f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
52661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(V|)K/) {
52671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(K|)V/) {
52701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
527207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
527307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($WeakSymbols{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}}) {
527407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Weak"} = 1;
527507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
527674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
527774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
527874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
527974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
528074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
528174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
528274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub guessHeader($)
528374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
528474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
528574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ShortName = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
528674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"};
528774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassName = $ClassId?get_ShortClass($ClassId, $Version):"";
528874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Header = $SymbolInfo{$Version}{$InfoId}{"Header"};
528974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $HPath = $SymbolHeader{$Version}{$ClassName}{$ShortName})
529074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
529174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(get_filename($HPath) eq $Header)
529274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
529374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $HDir = get_filename(get_dirname($HPath));
529474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($HDir ne "include"
529574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $HDir=~/\A[a-z]+\Z/i) {
529674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HDir, $Header);
529774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
529874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
529974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
530074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Header;
5301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInline($)
5304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # "body: undefined" in the tree
5305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # -fkeep-inline-functions GCC option should be specified
5306dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5307dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5308dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ undefined /i) {
5309dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return 0;
5310dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
5313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5315e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub hasThrow($)
5316e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5317e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5318e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5319e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5320e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return getTreeAttr_Unql($1, "unql");
5321e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5322e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5323e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return 1;
5324e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5325e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
5326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeId($)
5327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5328dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5329dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5330dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5331dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5332dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5334dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeMemb($$)
5338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeType = $TypeAttr->{"Type"};
53410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $UnnamedPos) = (0, 0);
534274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $StaticFields = 0;
5343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeType eq "Enum")
5344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53454b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Csts($TypeId);
53464b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"value"} = getEnumMembVal($MInfoId);
53494b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembName = getTreeStr(getTreeAttr_Purp($MInfoId));
535062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $MembName;
53514b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $EnumMembName_Id{$Version}{getTreeAttr_Valu($MInfoId)} = ($TypeAttr->{"NameSpace"})?$TypeAttr->{"NameSpace"}."::".$MembName:$MembName;
53524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
53530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeType=~/\A(Struct|Class|Union)\Z/)
5357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Flds($TypeId);
53594b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
53614b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $IType = $LibInfo{$Version}{"info_type"}{$MInfoId};
53624b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MInfo = $LibInfo{$Version}{"info"}{$MInfoId};
5363989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $IType or $IType ne "field_decl")
5364989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # search for fields, skip other stuff in the declaration
536574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
536674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($IType eq "var_decl")
536774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # static field
536874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $StaticFields = 1;
536974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
537074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
53714b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
53744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $StructMembName = getTreeStr(getTreeAttr_Name($MInfoId));
5375fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(index($StructMembName, "_vptr.")==0)
53761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual tables
5377fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $StructMembName = "_vptr";
5378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields
538101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($TypeAttr->{"Name"}, "_type_info_pseudo")==-1)
5382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
53834b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    my $UnnamedTid = getTreeAttr_Type($MInfoId);
5384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $UnnamedTName = getNameByInfo(getTypeDeclId($UnnamedTid));
5385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isAnon($UnnamedTName))
5386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # rename unnamed fields to unnamed0, unnamed1, ...
5387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $StructMembName = "unnamed".($UnnamedPos++);
5388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
5389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
5390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields and base classes
53934b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
53964b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembTypeId = getTreeAttr_Type($MInfoId);
539762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $MissedTypedef{$Version}{$MembTypeId})
539862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
539962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $AddedTid = $MissedTypedef{$Version}{$MembTypeId}{"Tid"}) {
540062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $MembTypeId = $AddedTid;
540162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
5402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
54040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"type"} = $MembTypeId;
54050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $StructMembName;
54064b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if((my $Access = getTreeAccess($MInfoId)) ne "public")
54071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # marked only protected and private, public by default
54080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"access"} = $Access;
54090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
54100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($MInfo=~/spec:\s*mutable /)
54110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # mutable fields
54120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"mutable"} = 1;
5413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
54144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $Algn = getAlgn($MInfoId)) {
5415f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"algn"} = $Algn;
5416f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
54174b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $BFSize = getBitField($MInfoId))
5418f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bits
54190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"bitfield"} = $BFSize;
5420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
5422f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bytes
5423177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($TypeAttr->{"Memb"}{$Pos}{"algn"}==1)
5424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                { # template
5425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($TypeAttr->{"Memb"}{$Pos}{"algn"});
5426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                else {
5428177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeAttr->{"Memb"}{$Pos}{"algn"} /= $BYTE_SIZE;
5429177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5431f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
54324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
54330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
543674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
543774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $StaticFields;
5438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncParams($)
5441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
54421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
544362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamInfoId = getTreeAttr_Args($InfoId);
5444f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5445f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5446f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5447f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check type of "this" pointer
544962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjectTypeId = getTreeAttr_Type($ParamInfoId);
545062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ObjectName = $TypeInfo{$Version}{$ObjectTypeId}{"Name"})
5451850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
545262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bconst(| volatile)\*const\b/) {
5453850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5454850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
545562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bvolatile\b/) {
5456850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5457850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
5458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5459850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else
5460850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # skip
5461850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
5462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5463ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # skip "this"-parameter
5464ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # $ParamInfoId = getNextElem($ParamInfoId);
5465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5466f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos, $Vtt_Pos) = (0, 0, -1);
5467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamInfoId)
54680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # formal args
546962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Type($ParamInfoId);
547062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamName = getTreeStr(getTreeAttr_Name($ParamInfoId));
547162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $ParamName)
547262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # unnamed
5473f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $ParamName = "p".($PPos+1);
5474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
547562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$ParamTypeId})
547662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
547762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$ParamTypeId}{"Tid"}) {
547862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ParamTypeId = $AddedTid;
547962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
548062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
548162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PType = $TypeInfo{$Version}{$ParamTypeId}{"Type"};
5482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $PType or $PType eq "Unknown") {
5483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
5484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
548562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PTName = $TypeInfo{$Version}{$ParamTypeId}{"Name"};
5486989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $PTName) {
5487989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return 1;
5488989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5489989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($PTName eq "void") {
5490989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            last;
5491989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ParamName eq "__vtt_parm"
549362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void const**")
5494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
54950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Vtt_Pos = $Pos;
5496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamInfoId = getNextElem($ParamInfoId);
5497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
54990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
5500177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my %Base = get_BaseType($ParamTypeId, $Version))
5502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5503177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Base{"Template"}) {
5504177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
5505177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5506177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5507177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
55080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = $ParamName;
550962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Algn = getAlgn($ParamInfoId)) {
551062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"algn"} = $Algn/$BYTE_SIZE;
551162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info"}{$ParamInfoId}=~/spec:\s*register /)
5513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # foo(register type arg)
55140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"reg"} = 1;
5515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamInfoId = getNextElem($ParamInfoId);
55170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5518f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($ParamName ne "this" or $FType ne "Method") {
5519f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5520f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
5521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(setFuncArgs($InfoId, $Vtt_Pos)) {
552301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = "-1";
5524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
5526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
55280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub setFuncArgs($$)
5529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
55301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($InfoId, $Vtt_Pos) = @_;
55311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $FuncTypeId = getFuncTypeId($InfoId);
553262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamListElemId = getTreeAttr_Prms($FuncTypeId);
5533f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5534f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5535f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5536f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
5537f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        # skip "this"-parameter
553846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        # $ParamListElemId = getNextElem($ParamListElemId);
5539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
55400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $ParamListElemId)
55410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # foo(...)
55420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
55430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
5544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HaveVoid = 0;
5545f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos) = (0, 0);
5546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamListElemId)
55470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # actual params: may differ from formal args
55480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # formal int*const
55490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # actual: int*
55500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Vtt_Pos!=-1 and $Pos==$Vtt_Pos)
5551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Vtt_Pos=-1;
5553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamListElemId = getNextElem($ParamListElemId);
5554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
555662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Valu($ParamListElemId);
555762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void")
5558dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $HaveVoid = 1;
5560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
5561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
556246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        else
5563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
556446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            if(not defined $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
556546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
556646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
556746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"})
556846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # unnamed
5569f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($PPos+1);
557046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
557146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            }
557246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            elsif(my $OldId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
557346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
5574e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if($Pos>0 or getFuncType($InfoId) ne "Method")
557546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # params
557646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    if($OldId ne $ParamTypeId)
557746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    {
557846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %Old_Pure = get_PureType($OldId, $TypeInfo{$Version});
557946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %New_Pure = get_PureType($ParamTypeId, $TypeInfo{$Version});
558046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko
558146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($Old_Pure{"Name"} ne $New_Pure{"Name"}) {
558246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
558346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
558446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    }
558546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
55860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
55870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
558862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $PurpId = getTreeAttr_Purp($ParamListElemId))
55890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # default arguments
559001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $PurpType = $LibInfo{$Version}{"info_type"}{$PurpId})
559101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
55928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($PurpType eq "nop_expr")
55938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # func ( const char* arg = (const char*)(void*)0 )
55948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $PurpId = getTreeAttr_Op($PurpId);
55958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
559601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                my $Val = getInitVal($PurpId, $ParamTypeId);
559701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(defined $Val) {
559801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"default"} = $Val;
559901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
5600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamListElemId = getNextElem($ParamListElemId);
5603f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Pos!=0 or $FType ne "Method") {
5604f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5605f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
56060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ($Pos>=1 and not $HaveVoid);
5609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
561162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chan($)
561262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
561362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
561462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
561562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chan[ ]*:[ ]*@(\d+) /) {
561662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
561762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
561862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
561962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
562062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
562162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
562262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chain($)
562362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
562462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
562562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
562662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chain[ ]*:[ ]*@(\d+) /) {
562762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
562862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
562962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
563062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
563162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
563262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5633e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub getTreeAttr_Unql($)
5634e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5635e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5636e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5637e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*@(\d+) /) {
5638e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return $1;
5639e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5640e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5641e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return "";
5642e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5643e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
564462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Scpe($)
564562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
564662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
564762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
564862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /) {
564962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
565062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
565162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
565262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
565362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
565462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
565562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Type($)
565662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
565762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
565862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
565962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
566062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
566162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
566262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
566362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
566462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
566562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
566662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Name($)
566762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
566862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
566962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
567062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /) {
567162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
567262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
567362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
567462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
567562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
567662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
567762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Mngl($)
567862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
567962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
568062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
568162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /) {
568262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
568362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
568462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
568562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
568662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
568762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
568862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Prms($)
568962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
569062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
569162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
569262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/prms[ ]*:[ ]*@(\d+) /) {
569362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
569462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
569562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
569662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
569762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
569862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
569962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Fncs($)
5700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5701dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5702dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
570362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/fncs[ ]*:[ ]*@(\d+) /) {
570462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
570562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
570662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
570762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
570862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
570962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
571062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Csts($)
571162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
571262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
571362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
571462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/csts[ ]*:[ ]*@(\d+) /) {
571562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
571662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
571762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
571862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
571962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
572062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
572162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Purp($)
572262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
572362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
572462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
572562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
572662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
572762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
572862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
572962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
573062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
573162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
57328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getTreeAttr_Op($)
57338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
57348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
57358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
57368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Info=~/op 0[ ]*:[ ]*@(\d+) /) {
57378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return $1;
57388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
57398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
57408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return "";
57418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
57428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
574362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Valu($)
574462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
574562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
574662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
574762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
574862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
574962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
575062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
575162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
575262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
575362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
575462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Flds($)
575562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
575662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
575762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
575862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/flds[ ]*:[ ]*@(\d+) /) {
575962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
576062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
576162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
576262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
576362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
576462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5765177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getTreeAttr_Binf($)
5766177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
5767177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5768177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
5769177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Info=~/binf[ ]*:[ ]*@(\d+) /) {
5770177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $1;
5771177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5772177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
5773177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "";
5774177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
5775177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
577662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Args($)
577762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
577862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
577962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
578062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/args[ ]*:[ ]*@(\d+) /) {
5781dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5782dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeValue($)
5788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5789dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5790dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5791dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/low[ ]*:[ ]*([^ ]+) /) {
5792dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5793dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeAccess($)
5799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5800dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5802dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/accs[ ]*:[ ]*([a-zA-Z]+) /)
5803dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5804dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            my $Access = $1;
5805dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Access eq "prot") {
5806dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "protected";
5807dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5808dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($Access eq "priv") {
5809dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "private";
5810dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5811dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5812dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ protected /)
5813dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "protected";
5815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5816dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ private /)
5817dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "private";
5819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "public";
5822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncAccess($)
5825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
58261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Access = getTreeAccess($_[0]);
5827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
58281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Protected"} = 1;
5829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
58311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Private"} = 1;
5832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeAccess($$)
5836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Access = getTreeAccess($TypeId);
5839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
5840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Protected"} = 1;
5841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
5843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Private"} = 1;
5844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncKind($)
5848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5849dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5850dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5851dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/pseudo tmpl/) {
5852dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"PseudoTemplate"} = 1;
5853dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5854dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ constructor /) {
5855dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Constructor"} = 1;
5856dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5857dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ destructor /) {
5858dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Destructor"} = 1;
5859dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5863989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub getVirtSpec($)
5864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5865dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5866dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5867dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/spec[ ]*:[ ]*pure /) {
5868dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5869dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5870dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/spec[ ]*:[ ]*virt /) {
5871dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5872dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5873dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ pure\s+virtual /)
5874dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5875dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
5876dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5877dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ virtual /)
5878dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5879dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
5880dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncLink($)
5886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5887dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5888dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5889dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/link[ ]*:[ ]*static /) {
5890dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Static";
5891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5892dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/link[ ]*:[ ]*([a-zA-Z]+) /) {
5893dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5896dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
589974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Symbol_NS($$)
5900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
590174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
590274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "" if(not $Symbol or not $LibVersion);
590374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $NS = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
590474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $NS)
590574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
590674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(my $Class = $CompleteSignature{$LibVersion}{$Symbol}{"Class"}) {
590774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $NS = $TypeInfo{$LibVersion}{$Class}{"NameSpace"};
590874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
5909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
591074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($NS)
5911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
591274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
591374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
591474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
591574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
591774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
591874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
591974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
592074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
592174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
592574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
592674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
592974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Type_NS($$)
5930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
5932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName or not $LibVersion);
593374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NS = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$TypeName}}{"NameSpace"})
5934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
593574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
593674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
593774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
593874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
5939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
594074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
594174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
594274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
594374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
594474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
5945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
594874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
5949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameSpace($)
5952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
595374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
595474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NSInfoId = getTreeAttr_Scpe($InfoId))
5955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
595662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
5957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
595862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($InfoType eq "namespace_decl")
5959dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
596062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($LibInfo{$Version}{"info"}{$NSInfoId}=~/name[ ]*:[ ]*@(\d+) /)
596162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
596262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $NameSpace = getTreeStr($1);
596362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($NameSpace eq "::")
596462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # global namespace
596562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "";
596662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
596762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BaseNameSpace = getNameSpace($NSInfoId)) {
596862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NameSpace = $BaseNameSpace."::".$NameSpace;
596962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
597062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $NestedNameSpaces{$Version}{$NameSpace} = 1;
597162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return $NameSpace;
597262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
597362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
597462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return "";
5975dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
5976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5977177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            elsif($InfoType ne "function_decl")
597862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # inside data type
597962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($Name, $NameNS) = getTrivialName(getTypeDeclId($NSInfoId), $NSInfoId);
598062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Name;
598162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
5982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5984dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getEnumMembVal($)
5988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5989dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5991dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*\@(\d+)/)
5992dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5993dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $VInfo = $LibInfo{$Version}{"info"}{$1})
5994dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
5995dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($VInfo=~/cnst[ ]*:[ ]*\@(\d+)/)
5996dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # in newer versions of GCC the value is in the "const_decl->cnst" node
5997dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
5998dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
5999dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                else
6000dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # some old versions of GCC (3.3) have the value in the "integer_cst" node
6001dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6002dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6003dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSize($)
6010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6011dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6012dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6013dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/size[ ]*:[ ]*\@(\d+)/) {
6014dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getTreeValue($1);
6015dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6017dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAlgn($)
6021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6022dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6023dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6024dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/algn[ ]*:[ ]*(\d+) /) {
6025dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6031f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getBitField($)
6032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6033dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6035dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ bitfield /) {
6036dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getSize($_[0]);
6037dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6039dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
604262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getNextElem($)
6043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
604462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Chan = getTreeAttr_Chan($_[0])) {
604562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chan;
6046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
604762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(my $Chain = getTreeAttr_Chain($_[0])) {
604862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chain;
6049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6050dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
605362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub registerHeader($$)
605462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # input: absolute path of header, relative path or name
6055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
605662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
605762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
6058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
605962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
606062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
606162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$Header\'");
6062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
606362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(skipHeader($Header, $LibVersion))
606462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # skip
6065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
6066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
606762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Header_Path = identifyHeader($Header, $LibVersion))
606862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
606962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        detect_header_includes($Header_Path, $LibVersion);
607062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
60718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(defined $Tolerance and $Tolerance=~/3/)
60728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # 3 - skip headers that include non-Linux headers
60738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($OSgroup ne "windows")
60748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
60758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Inc (keys(%{$Header_Includes{$LibVersion}{$Header_Path}}))
60768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
60778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(specificHeader($Inc, "windows")) {
60788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        return "";
60798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
60808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
60818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
60828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
60838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
608462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RHeader_Path = $Header_ErrorRedirect{$LibVersion}{$Header_Path})
608562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # redirect
608662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Registered_Headers{$LibVersion}{$RHeader_Path}{"Identity"}
608762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            or skipHeader($RHeader_Path, $LibVersion))
608862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # skip
608962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return "";
609062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
609162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Header_Path = $RHeader_Path;
609262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
609362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Header_ShouldNotBeUsed{$LibVersion}{$Header_Path})
609462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip
609562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "";
609662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
609762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
609862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HName = get_filename($Header_Path))
609962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # register
610062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Registered_Headers{$LibVersion}{$Header_Path}{"Identity"} = $HName;
610162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HeaderName_Paths{$LibVersion}{$HName}{$Header_Path} = 1;
610262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
610362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
610462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(($Header=~/\.(\w+)\Z/ and $1 ne "h")
610562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Header!~/\.(\w+)\Z/)
61068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # hpp, hh, etc.
610762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            setLanguage($LibVersion, "C++");
61088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CPP_HEADERS = 1;
610962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
611062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
611162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CheckHeadersOnly
611262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Header=~/(\A|\/)c\+\+(\/|\Z)/)
611362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # /usr/include/c++/4.6.1/...
611462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $STDCXX_TESTING = 1;
611562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
611662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
611762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header_Path;
6118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
611962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
6120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub registerDir($$$)
6123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $WithDeps, $LibVersion) = @_;
6125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//g;
6126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not $Dir or not -d $Dir);
6127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir = get_abs_path($Dir);
6128f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mode = "All";
6130850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($WithDeps)
6131850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}) {
6133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RegisteredDirs{$LibVersion}{$Dir}{0}) {
6136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mode = "DepsOnly";
6137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6139850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
6140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}
6142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $RegisteredDirs{$LibVersion}{$Dir}{0}) {
6143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Header_Dependency{$LibVersion}{$Dir} = 1;
6147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $RegisteredDirs{$LibVersion}{$Dir}{$WithDeps} = 1;
6148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mode eq "DepsOnly")
6149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6150570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (cmd_find($Dir,"d")) {
6151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Dependency{$LibVersion}{$Path} = 1;
6152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
6154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6155570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (sort {length($b)<=>length($a)} cmd_find($Dir,"f"))
6156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($WithDeps)
6158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $SubDir = $Path;
6160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while(($SubDir = get_dirname($SubDir)) ne $Dir)
6161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # register all sub directories
6162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Dependency{$LibVersion}{$SubDir} = 1;
6163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(is_not_header($Path));
6166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
6167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Neighbors
61689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $Part (get_prefixes($Path)) {
6169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Neighbors{$LibVersion}{$Part} = $Path;
6170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_filename($Dir) eq "include")
6173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for "lib/include/" directory
6174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $LibDir = $Dir;
6175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibDir=~s/([\/\\])include\Z/$1lib/g and -d $LibDir) {
61768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($LibDir, $WithDeps, $LibVersion);
6177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_redirect($$$)
6182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path, $LibVersion) = @_;
6184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Errors = ();
6185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Content=~s/#\s*error\s+([^\n]+?)\s*(\n|\Z)//) {
6186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Errors, $1);
6187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Redirect = "";
6189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Errors)
6190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        s/\s{2,}/ /g;
6192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/(only|must\ include
6193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |update\ to\ include
6194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ with
6195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ by|renamed\ to
61969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        |\ is\ in|\ use)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))/ix)
6197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/(include|use|is\ in)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))\ instead/i)
6202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/this\ header\ should\ not\ be\ used
6207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |programs\ should\ not\ directly\ include
6208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |you\ should\ not\ (include|be\ (including|using)\ this\ (file|header))
6209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |is\ not\ supported\ API\ for\ general\ use
6210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |do\ not\ use
62119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko         |should\ not\ be\ (used|using)
6212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |cannot\ be\ included\ directly/ix and not /\ from\ /i) {
6213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
6214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6216850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Redirect)
6217850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6218850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/\A<//g;
6219850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/>\Z//g;
6220850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6221850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return $Redirect;
6222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_includes($$)
6225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path) = @_;
6227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Includes = ();
622874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]*([<"].+?[">])[ \t]*//m)
6229850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # C/C++: include, Objective C/C++: import directive
62304b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $Header = $2;
623174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $Method = substr($Header, 0, 1, "");
623274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        substr($Header, length($Header)-1, 1, "");
623374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Header = path_format($Header, $OSgroup);
623474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Method eq "\"" or is_abs($Header))
623574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
623674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-e join_P(get_dirname($Path), $Header))
623774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # relative path exists
623874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = -1;
6239850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
624074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            else
624174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # include "..." that doesn't exist is equal to include <...>
624274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = 2;
6243850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
624574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else {
624674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$Header} = 1;
624774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
624874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
624974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
625074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
625174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]+(\w+)[ \t]*//m)
625274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # FT_FREETYPE_H
625374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$2} = 0;
6254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Includes;
6257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ignore_path($)
6260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\~\Z/)
6263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping system backup files
6264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/(\A|[\/\\]+)(\.(svn|git|bzr|hg)|CVS)([\/\\]+|\Z)/)
6267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping hidden .svn, .git, .bzr, .hg and CVS directories
6268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortByWord($$)
6274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $W) = @_;
6276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($W)<2);
6277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_filename($b)=~/\Q$W\E/i<=>get_filename($a)=~/\Q$W\E/i} @{$ArrRef};
6278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortHeaders($$)
6281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($H1, $H2) = @_;
62838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H1=~s/\.[a-z]+\Z//ig;
6285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H2=~s/\.[a-z]+\Z//ig;
62868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
62878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname1 = get_filename($H1);
62888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname2 = get_filename($H2);
62898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir1 = get_dirname($H1);
62908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir2 = get_dirname($H2);
6291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname1 = get_filename($HDir1);
6292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname2 = get_filename($HDir2);
62938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
62948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir1=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
62958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir2=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
62968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
62979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[0] eq $_[1]
62989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    or $H1 eq $H2) {
6299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H1=~/\A\Q$H2\E/) {
6302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H2=~/\A\Q$H1\E/) {
6305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir1=~/\Q$Hname1\E/i
6308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir2!~/\Q$Hname2\E/i)
63099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir2=~/\Q$Hname2\E/i
6313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir1!~/\Q$Hname1\E/i)
63149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname1=~/\Q$Dirname1\E/i
6318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname2!~/\Q$Dirname2\E/i)
63199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname2=~/\Q$Dirname2\E/i
6323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname1!~/\Q$Dirname1\E/i)
63249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname1=~/(config|lib|util)/i
63289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname2!~/(config|lib|util)/i)
63299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname2=~/(config|lib|util)/i
63339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname1!~/(config|lib|util)/i)
63349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
63379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
63389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
63398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R1 = checkRelevance($H1);
63408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R2 = checkRelevance($H2);
63418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($R1 and not $R2)
63428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return -1;
63448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        elsif($R2 and not $R1)
63468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
63478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
63488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
63498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
63508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
63518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return (lc($H1) cmp lc($H2));
63528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
6353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub searchForHeaders($)
6357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
6359570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # gcc standard include paths
6361570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    registerGccHeaders();
6362570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" and not $STDCXX_TESTING)
6364570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # c++ standard include paths
6365570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        registerCppHeaders();
6366570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6367570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing header paths
6369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$Descriptor{$LibVersion}{"IncludePaths"}},
6370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    @{$Descriptor{$LibVersion}{"AddIncludePaths"}})
6371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IPath = $Path;
6373a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($SystemRoot)
6374a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
6375a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(is_abs($Path)) {
6376a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Path = $SystemRoot.$Path;
6377a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
6378a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        }
6379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Path) {
6380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Path\'");
6381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path) {
6383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "\'$Path\' - not a directory");
6384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Path)
6386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = get_abs_path($Path);
63888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 0, $LibVersion);
6389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(grep {$IPath eq $_} @{$Descriptor{$LibVersion}{"AddIncludePaths"}}) {
6390570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Add_Include_Paths{$LibVersion}}, $Path);
6391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
6393570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Include_Paths{$LibVersion}}, $Path);
6394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6397570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$Include_Paths{$LibVersion}}) {
6398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $INC_PATH_AUTODETECT{$LibVersion} = 0;
6399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6400570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering directories
6402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -e $Path);
6405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
6406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
6407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path) {
64088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 1, $LibVersion);
6409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path)
6411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($Path);
6413570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not grep { $Dir eq $_ } (@{$SystemPaths{"include"}})
6414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $LocalIncludes{$Dir})
6415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
64168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                registerDir($Dir, 1, $LibVersion);
6417fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # if(my $OutDir = get_dirname($Dir))
6418fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # { # registering the outer directory
6419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     if(not grep { $OutDir eq $_ } (@{$SystemPaths{"include"}})
6420fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     and not $LocalIncludes{$OutDir}) {
6421fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #         registerDir($OutDir, 0, $LibVersion);
6422fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     }
6423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # }
6424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6427850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6428850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6429850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %RegisteredDirs = ();
6430850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering headers
6432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Position = 0;
6433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Dest) and not -e $Dest) {
6436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
6437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest = path_format($Dest, $OSgroup);
6439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_header($Dest, 1, $LibVersion))
6440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
644162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HPath = registerHeader($Dest, $LibVersion)) {
6442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$HPath}{"Pos"} = $Position++;
6443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Dest)
6446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Registered = ();
6448570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"f"))
6449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
6451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(not is_header($Path, 0, $LibVersion));
645262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $HPath = registerHeader($Path, $LibVersion)) {
6453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Registered, $HPath);
6454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
64569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            @Registered = sort {sortHeaders($a, $b)} @Registered;
64579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            sortByWord(\@Registered, $TargetLibraryShortName);
6458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (@Registered) {
6459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$Path}{"Pos"} = $Position++;
6460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
6463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't identify \'$Dest\' as a header file");
6464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
64678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/4/)
64688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 4 - skip headers included by others
64698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
64708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
6471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Header_Includes_R{$LibVersion}{$Path}) {
64728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($Registered_Headers{$LibVersion}{$Path});
64738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
64748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
64758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
64768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6477dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $HList = $Descriptor{$LibVersion}{"IncludePreamble"})
6478dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # preparing preamble headers
6479dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, $HList))
6480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6481dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(is_abs($Header) and not -f $Header) {
6482dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$Header\'");
6483dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6484dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Header = path_format($Header, $OSgroup);
6485dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Header_Path = is_header($Header, 1, $LibVersion))
6486dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
648762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(skipHeader($Header_Path, $LibVersion));
6488570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($Include_Preamble{$LibVersion}, $Header_Path);
6489dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6490dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else {
6491dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't identify \'$Header\' as a header file");
6492dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Header_Name (keys(%{$HeaderName_Paths{$LibVersion}}))
6496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # set relative paths (for duplicates)
6497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})>=2)
6498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for duplicates
6499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $FirstPath = (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))[0];
6500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Prefix = get_dirname($FirstPath);
6501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while($Prefix=~/\A(.+)[\/\\]+[^\/\\]+\Z/)
6502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # detect a shortest distinguishing prefix
6503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $NewPrefix = $1;
6504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my %Identity = ();
6505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
6507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Path=~/\A\Q$Prefix\E[\/\\]+(.*)\Z/) {
6508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Identity{$Path} = $1;
6509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(keys(%Identity)==keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
65126fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko                { # all names are different with current prefix
6513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})) {
6514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Registered_Headers{$LibVersion}{$Path}{"Identity"} = $Identity{$Path};
6515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
6517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Prefix = $NewPrefix; # increase prefix
6519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6522850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6523850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6524850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %HeaderName_Paths = ();
6525850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (keys(%{$Include_Order{$LibVersion}}))
6527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ordering headers according to descriptor
65288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $PairName = $Include_Order{$LibVersion}{$HeaderName};
6529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Pos, $PairPos) = (-1, -1);
6530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Path, $PairPath) = ();
6531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = keys(%{$Registered_Headers{$LibVersion}});
6532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Paths = sort {int($Registered_Headers{$LibVersion}{$a}{"Pos"})<=>int($Registered_Headers{$LibVersion}{$b}{"Pos"})} @Paths;
6533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header_Path (@Paths)
6534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $PairName)
6536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPath = $Header_Path;
6539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $HeaderName)
6541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Pos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Header_Path;
6544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PairPos!=-1 and $Pos!=-1
6547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and int($PairPos)<int($Pos))
6548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Tmp = %{$Registered_Headers{$LibVersion}{$Path}};
6550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$Path}} = %{$Registered_Headers{$LibVersion}{$PairPath}};
6551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$PairPath}} = %Tmp;
6552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Registered_Headers{$LibVersion}})) {
6555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "header files are not found in the ".$Descriptor{$LibVersion}{"Version"});
6556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_real_includes($$)
6560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $LibVersion or not $AbsPath or not -e $AbsPath);
6563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}
6564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6567850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}=1;
6568850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = callPreprocessor($AbsPath, "", $LibVersion);
6570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path);
6571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    open(PREPROC, $Path);
6572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(<PREPROC>)
6573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/#\s+\d+\s+"([^"]+)"[\s\d]*\n/)
6575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Include = path_format($1, $OSgroup);
6577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include=~/\<(built\-in|internal|command(\-|\s)line)\>|\A\./) {
6578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include eq $AbsPath) {
6581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$Include} = 1;
6584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
6587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_header_includes($$)
6591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
6593850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $LibVersion or not $Path);
6594850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"detect_header_includes"}{$LibVersion}{$Path}) {
6595850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6596850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6597850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_header_includes"}{$LibVersion}{$Path}=1;
6598850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6599850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not -e $Path) {
6600850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6601850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6602850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($Path);
6604850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Redirect = parse_redirect($Content, $Path, $LibVersion))
6605850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # detect error directive in headers
660662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RedirectPath = identifyHeader($Redirect, $LibVersion))
6607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath=~/\/usr\/include\// and $Path!~/\/usr\/include\//) {
660962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $RedirectPath = identifyHeader(get_filename($Redirect), $LibVersion);
6610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath ne $Path) {
6612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_ErrorRedirect{$LibVersion}{$Path} = $RedirectPath;
6613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
66159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
66169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # can't find
66179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
66189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
6619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Inc = parse_includes($Content, $Path))
6621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Include (keys(%{$Inc}))
6623850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # detect includes
6624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Header_Includes{$LibVersion}{$Path}{$Include} = $Inc->{$Include};
66258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
66268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Tolerance and $Tolerance=~/4/)
66278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
66288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $HPath = identifyHeader($Include, $LibVersion))
66298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
66308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Header_Includes_R{$LibVersion}{$HPath}{$Path} = 1;
66318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
66328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
6633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
6634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub fromLibc($)
663874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC header
6639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $Name) = separate_path($Path);
6641fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6642fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6643fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($Dir) eq "libc" and $GlibcHeader{$Name})
6644fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{stdio, ...}.h
6645fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6647fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6648fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6649fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6650fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Dir eq "/usr/include" and $GlibcHeader{$Name})
6651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{stdio, ...}.h
6652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLibcDir($)
665974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC directory
6660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
6661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($OutDir, $Name) = separate_path($Dir);
6662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($OutDir) eq "libc"
6665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{sys,bits,asm,asm-*}/*.h
6667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6671fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # linux
6672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($OutDir eq "/usr/include"
6673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{sys,bits,asm,asm-*}/*.h
6675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_recursive_includes($$)
6682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath);
6685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isCyclical(\@RecurInclude, $AbsPath)) {
6686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsDir, $Name) = separate_path($AbsPath);
6689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isLibcDir($AbsDir))
669074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # system GLIBC internals
669174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return () if(not $ExtraInfo);
6692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($OSgroup ne "windows" and $Name=~/windows|win32|win64/i);
6697570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6698570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($MAIN_CPP_DIR and $AbsPath=~/\A\Q$MAIN_CPP_DIR\E/ and not $STDCXX_TESTING)
6699570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # skip /usr/include/c++/*/ headers
6700570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return () if(not $ExtraInfo);
6701570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6702570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurInclude, $AbsPath);
6704570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep { $AbsDir eq $_ } @DefaultGccPaths
670574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    or (grep { $AbsDir eq $_ } @DefaultIncPaths and fromLibc($AbsPath)))
6706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check "real" (non-"model") include paths
6707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = detect_real_includes($AbsPath, $LibVersion);
6708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        pop(@RecurInclude);
6709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @Paths;
6710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Header_Includes{$LibVersion}{$AbsPath}})) {
6712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_header_includes($AbsPath, $LibVersion);
6713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Include (keys(%{$Header_Includes{$LibVersion}{$AbsPath}}))
6715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $IncType = $Header_Includes{$LibVersion}{$AbsPath}{$Include};
6717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HPath = "";
6718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType<0)
6719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for #include "..."
672074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P($AbsDir, $Include);
6721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
672274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $HPath = realpath($Candidate);
6723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6725850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($IncType>0
67261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Include=~/[\/\\]/) # and not find_in_defaults($Include)
6727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for the nearest header
6728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # QtCore/qabstractanimation.h includes <QtCore/qobject.h>
672974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P(get_dirname($AbsDir), $Include);
6730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
6731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $HPath = $Candidate;
6732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HPath) {
673562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HPath = identifyHeader($Include, $LibVersion);
6736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HPath);
6738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HPath eq $AbsPath) {
6739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
6740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
67419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
67429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Debug)
67439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # boundary headers
674474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             if($HPath=~/vtk/ and $AbsPath!~/vtk/)
674574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             {
674674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#                 print STDERR "$AbsPath -> $HPath\n";
674774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             }
67489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
67499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
6750850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RecursiveIncludes{$LibVersion}{$AbsPath}{$HPath} = $IncType;
6751850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType>0)
6752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only include <...>, skip include "..." prefixes
6753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Include_Prefix{$LibVersion}{$AbsPath}{$HPath}{get_dirname($Include)} = 1;
6754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $IncPath (detect_recursive_includes($HPath, $LibVersion))
6756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($IncPath eq $AbsPath) {
6758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6760850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $RIncType = $RecursiveIncludes{$LibVersion}{$HPath}{$IncPath};
6761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($RIncType==-1)
6762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # include "..."
6763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $RIncType = $IncType;
6764850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($RIncType==2)
6766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
6767850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($IncType!=-1) {
6768850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $RIncType = $IncType;
6769850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
6770850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6771850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$IncPath} = $RIncType;
6772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$HPath}{$IncPath}})) {
6773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Include_Prefix{$LibVersion}{$AbsPath}{$IncPath}{$Prefix} = 1;
6774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dep (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}}))
6777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GlibcHeader{get_filename($Dep)} and keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}})>=2
6779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""})
6780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # distinguish math.h from glibc and math.h from the tested library
6781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""});
6782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                last;
6783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurInclude);
6787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_framework($$$)
6791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Framework, $LibVersion) = @_;
6793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header or not $Framework or not $LibVersion);
6794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header}) {
6795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header};
6796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dependency (sort {get_depth($a)<=>get_depth($b)} keys(%{$Header_Dependency{$LibVersion}}))
6798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_filename($Dependency) eq $Framework
6800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and -f get_dirname($Dependency)."/".$Header) {
6801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = get_dirname($Dependency));
6802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = "");
6805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_defaults($)
6808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Header = $_[0];
6810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header);
6811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_defaults"}{$Header}) {
6812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_defaults"}{$Header};
6813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6814570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultIncPaths,
6815570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultGccPaths,
6816570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultCppPaths,
6817570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @UsersIncPath)
6818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Dir);
6820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Dir."/".$Header) {
6821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_defaults"}{$Header}=$Dir);
6822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_defaults"}{$Header}="");
6825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_paths($$)
6828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path1, $Path2) = @_;
6830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts1 = split(/[\/\\]/, $Path1);
6831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts2 = split(/[\/\\]/, $Path2);
6832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Num (0 .. $#Parts1)
6833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part1 = $Parts1[$Num];
6835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part2 = $Parts2[$Num];
6836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GlibcDir{$Part1}
6837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part2}) {
6838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($GlibcDir{$Part2}
6841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part1}) {
6842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1=~/glib/
6845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2!~/glib/) {
6846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1!~/glib/
6849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2=~/glib/) {
6850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
6851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $CmpRes = ($Part1 cmp $Part2)) {
6853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $CmpRes;
6854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkRelevance($)
6860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
68618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
6862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Path);
68638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot) {
6865a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Path = cut_path_prefix($Path, $SystemRoot);
6866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
68678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
68688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = lc(get_filename($Path));
68698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = lc(get_dirname($Path));
68708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6871a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $Name=~s/\.\w+\Z//g; # remove extension (.h)
68728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
68738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Token (split(/[_\d\W]+/, $Name))
6874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
68758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Len = length($Token);
68768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if($Len<=1);
68778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Dir=~/(\A|lib|[_\d\W])\Q$Token\E([_\d\W]|lib|\Z)/)
68788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # include/evolution-data-server-1.4/libebook/e-book.h
68798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
68808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
68818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Len>=4 and index($Dir, $Token)!=-1)
6882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # include/gupnp-1.0/libgupnp/gupnp-context.h
6883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkFamily(@)
6890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Paths = @_;
6892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#Paths<=0);
6893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefix = ();
6894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (@Paths)
6895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
6897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = cut_path_prefix($Path, $SystemRoot);
6898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($Path))
6900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Dir=~s/(\/[^\/]+?)[\d\.\-\_]+\Z/$1/g; # remove version suffix
6902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{$Dir} += 1;
6903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{get_dirname($Dir)} += 1;
6904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort keys(%Prefix))
6907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_depth($_)>=3
6909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Prefix{$_}==$#Paths+1) {
6910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAcceptable($$$)
6917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_dirname($Header))
6921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # with prefix
6922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HName=~/config|setup/i and $Candidate=~/[\/\\]lib\d*[\/\\]/)
6925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for glibconfig.h in /usr/lib/glib-2.0/include/
6926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkRelevance($Candidate))
6929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for atk.h in /usr/include/atk-1.0/atk/
6930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkFamily(getSystemHeaders($HName, $LibVersion)))
6933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # /usr/include/qt4/QtNetwork/qsslconfiguration.h
6934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # /usr/include/qt4/Qt/qsslconfiguration.h
6935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]stdapis[\/\\]/) {
6940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
6941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRelevant($$$)
6947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # disallow to search for "abstract" headers in too deep directories
6948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
6949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
6950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
6951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\](tools|stlportv5)[\/\\]/) {
6953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "bsd")
69579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
6958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]include[\/\\]bsd[\/\\]/)
6959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # openssh: skip /usr/lib/bcc/include/bsd/signal.h
6960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
69639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "windows")
69649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
69659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Candidate=~/[\/\\](wine|msvcrt|windows)[\/\\]/)
69669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # skip /usr/include/wine/msvcrt
69679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return 0;
69689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
69699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
6970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
6971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate=~/[\/\\]wx[\/\\]/)
6972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # do NOT search in system /wx/ directory
6973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for headers without a prefix: sstream.h
6974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/c\+\+[\/\\]\d+/ and $MAIN_CPP_DIR
6977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\A\Q$MAIN_CPP_DIR\E/)
6978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip ../c++/3.3.3/ if using ../c++/4.5/
6979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/[\/\\]asm-/
6982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and (my $Arch = getArch($LibVersion)) ne "unknown")
6983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # arch-specific header files
6984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate!~/[\/\\]asm-\Q$Arch\E/)
6985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {# skip ../asm-arm/ if using x86 architecture
6986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
6987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = getSystemHeaders($HName, $LibVersion);
6990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#Candidates==1)
6991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique header
6992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SCandidates = getSystemHeaders($Header, $LibVersion);
6995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#SCandidates==1)
6996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique name
6997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SystemDepth = $SystemRoot?get_depth($SystemRoot):0;
7000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_depth($Candidate)-$SystemDepth>=5)
7001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # abstract headers in too deep directories
7002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # sstream.h or typeinfo.h in /usr/include/wx-2.9/wx/
7003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isAcceptable($Header, $Candidate, $LibVersion)) {
7004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header eq "parser.h"
7008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\/libxml2\//)
7009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # select parser.h from xml2 library
7010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$SystemHeaders{$HName}})>=3)
7014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # many headers with the same name
7015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # like thread.h included without a prefix
7016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not checkFamily(@Candidates)) {
7017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
7021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub selectSystemHeader($$)
702462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
702562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"selectSystemHeader"}{$_[1]}{$_[0]}) {
702662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"selectSystemHeader"}{$_[1]}{$_[0]};
702762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
702862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"selectSystemHeader"}{$_[1]}{$_[0]} = selectSystemHeader_I(@_));
702962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
703062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
703162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectSystemHeader_I($$)
7032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
703462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(-f $Header) {
703562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header;
703662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
703762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
703862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
703962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
704062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $ConfHeaders{lc($Header)})
704262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # too abstract configuration headers
704362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
704462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
70459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $HName = get_filename($Header);
7046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
7047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
70489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $WinHeaders{lc($HName)}
70499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        or $HName=~/windows|win32|win64/i)
705062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # windows headers
7051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
70539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
70549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup ne "macos")
70559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
70569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($HName eq "fp.h")
705774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # pngconf.h includes fp.h in Mac OS
7058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
706174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
706274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(defined $ObsoleteHeaders{$HName})
706374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # obsolete headers
706474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return "";
7065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
706674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "linux" or $OSgroup eq "bsd")
706707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
706874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $AlienHeaders{$HName}
706974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or defined $AlienHeaders{$Header})
707074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # alien headers from other systems
707107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            return "";
707207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
707307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
707462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7075570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"include"}})
7076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in default paths
7077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Header) {
707874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path,$Header);
7079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7081e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"})
708262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # register all headers in system include dirs
7083e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
7084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort {get_depth($a)<=>get_depth($b)}
7086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort {cmp_paths($b, $a)} getSystemHeaders($Header, $LibVersion))
7087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isRelevant($Header, $Candidate, $LibVersion)) {
708962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Candidate;
7090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
709262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # error
709362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSystemHeaders($$)
7097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = ();
7100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort keys(%{$SystemHeaders{$Header}}))
7101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
710262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(skipHeader($Candidate, $LibVersion)) {
7103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
7104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Candidates, $Candidate);
7106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Candidates;
7108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_path_prefix($$)
7111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Prefix) = @_;
7113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path if(not $Prefix);
7114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Prefix=~s/[\/\\]+\Z//;
7115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path=~s/\A\Q$Prefix\E([\/\\]+|\Z)//;
7116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_default_include_dir($)
7120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
7122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//;
7123570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return grep { $Dir eq $_ } (@DefaultGccPaths, @DefaultCppPaths, @DefaultIncPaths);
7124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
712662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader($$)
712762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
7128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
712962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
713062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
7131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
713262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Header=~s/\A(\.\.[\\\/])+//g;
713362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"identifyHeader"}{$LibVersion}{$Header}) {
713462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"identifyHeader"}{$LibVersion}{$Header};
7135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
713662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"identifyHeader"}{$LibVersion}{$Header} = identifyHeader_I($Header, $LibVersion));
7137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
713962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader_I($$)
7140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search for header by absolute path, relative path or name
7141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header)
7143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # it's relative or absolute path
7144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return get_abs_path($Header);
7145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($GlibcHeader{$Header} and not $GLIBC_TESTING
7147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $HeaderDir = find_in_defaults($Header))
7148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for libc headers in the /usr/include
7149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for non-libc target library before searching
7150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # in the library paths
715174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($HeaderDir,$Header);
7152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $Path = $Include_Neighbors{$LibVersion}{$Header})
7154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the target library paths
7155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Path;
7156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7157570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultGccHeader{$Header})
7158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the internal GCC include paths
7159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultGccHeader{$Header};
7160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7161dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(my $DefaultDir = find_in_defaults($Header))
7162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default GCC include paths
716374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($DefaultDir,$Header);
7164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7165570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultCppHeader{$Header})
7166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default G++ include paths
7167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultCppHeader{$Header};
7168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $AnyPath = selectSystemHeader($Header, $LibVersion))
7170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search everywhere in the system
7171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $AnyPath;
7172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
717362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($OSgroup eq "macos")
717462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # search in frameworks: "OpenGL/gl.h" is "OpenGL.framework/Headers/gl.h"
717562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Dir = get_dirname($Header))
717662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
717762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $RelPath = "Headers\/".get_filename($Header);
717862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HeaderDir = find_in_framework($RelPath, $Dir.".framework", $LibVersion)) {
717974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HeaderDir, $RelPath);
718062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
718162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
7182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
718362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # cannot find anything
718462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLocation($)
7188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7189dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7190dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7191dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/srcp[ ]*:[ ]*([\w\-\<\>\.\+\/\\]+):(\d+) /) {
71929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return (path_format($1, $OSgroup), $2);
7193dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
71950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ();
7196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameByInfo($)
7199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7200989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7201dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7202dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /)
7203dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
7204dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $NInfo = $LibInfo{$Version}{"info"}{$1})
7205dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
7206dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($NInfo=~/strg[ ]*:[ ]*(.*?)[ ]+lngt/)
7207dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # short unsigned int (may include spaces)
72088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Str = $1;
72098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($CppMode{$Version}
72108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $Str=~/\Ac99_(.+)\Z/)
72118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
72128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($CppKeywords_A{$1}) {
72138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            $Str=$1;
72148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
72158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
72168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return $Str;
7217dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
7218dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
7219dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7221dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
7222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeStr($)
7225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7226989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7228989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/strg[ ]*:[ ]*([^ ]*)/)
7229989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7230989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Str = $1;
723107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}
7232570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $Str=~/\Ac99_(.+)\Z/)
7233570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
7234989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CppKeywords_A{$1}) {
7235989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $Str=$1;
7236989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7238989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $Str;
7239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7241989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncShortName($)
7245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7246989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7248570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(index($Info, " operator ")!=-1)
7249989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7250570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Info, " conversion ")!=-1)
725162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
725262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Rid = $SymbolInfo{$Version}{$_[0]}{"Return"})
725362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
725462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $RName = $TypeInfo{$Version}{$Rid}{"Name"}) {
725562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator ".$RName;
725662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
725762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
7258989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7259989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
7260989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
726162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Info=~/ operator[ ]+([a-zA-Z]+) /)
726262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
726362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $Ind = $Operator_Indication{$1}) {
726462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator".$Ind;
726562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
726662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    elsif(not $UnknownOperator{$1})
726762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
726862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        printMsg("WARNING", "unknown operator $1");
726962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $UnknownOperator{$1} = 1;
727062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
7271989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7272989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7276989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+) /) {
7277989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return getTreeStr($1);
7278989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7281989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncReturn($)
7285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7286989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7287989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7288989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7289989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7290989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/retn[ ]*:[ ]*@(\d+) /) {
7291989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return $1;
7292989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncOrig($)
7299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7300989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7301989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7302989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/orig[ ]*:[ ]*@(\d+) /) {
7303989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7304989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7306989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return $_[0];
7307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangleArray(@)
7310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7311dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0]=~/\A\?/)
7312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC mangling
7313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UndNameCmd = get_CmdPath("undname");
7314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UndNameCmd) {
7315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"undname\"");
7316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        writeFile("$TMP_DIR/unmangle", join("\n", @_));
7318a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return split(/\n/, `$UndNameCmd 0x8386 \"$TMP_DIR/unmangle\"`);
7319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC mangling
7322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CppFiltCmd = get_CmdPath("c++filt");
7323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CppFiltCmd) {
7324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find c++filt in PATH");
7325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
73269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not defined $CPPFILT_SUPPORT_FILE)
73279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
73289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $Info = `$CppFiltCmd -h 2>&1`;
73299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $CPPFILT_SUPPORT_FILE = $Info=~/\@<file>/;
73309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
7331570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $NoStrip = ($OSgroup=~/macos|windows/)?"-n":"";
73329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CPPFILT_SUPPORT_FILE)
73339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # new versions of c++filt can take a file
73349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_CPPFILT_FILE_SIZE)
73359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # c++filt <= 2.22 may crash on large files (larger than 8mb)
73369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # this is fixed in the oncoming version of Binutils
73379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
73389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
73399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
73409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            else
73419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
73429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                writeFile("$TMP_DIR/unmangle", join("\n", @_));
73439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip \@\"$TMP_DIR/unmangle\"`;
73449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_CPPFILT_FILE_SIZE constant");
73479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old-style unmangling
73539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_COMMAND_LINE_ARGUMENTS)
73549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
7355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
7356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
7357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
7359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Strings = join(" ", @_);
73619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip $Strings`;
73629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
73639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
73649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_COMMAND_LINE_ARGUMENTS constant");
73659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
73669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_ChargeLevel($$)
7373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
737462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
737562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if($Symbol!~/\A(_Z|\?)/);
737662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
737762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
7378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
737962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"})
7380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7381f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/C1[EI]/) {
7382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7384f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/C2[EI]/) {
7385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
738862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"})
7389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7390f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/D1[EI]/) {
7391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7393f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D2[EI]/) {
7394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7396f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D0[EI]/) {
7397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge-deleting]";
7398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7403f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Symbol=~/C1[EI]/) {
7404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7406f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/C2[EI]/) {
7407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7409f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D1[EI]/) {
7410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7412f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D2[EI]/) {
7413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7415f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D0[EI]/) {
7416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge-deleting]";
7417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub get_Signature_M($$)
74230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
74240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
74250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Signature_M = $tr_name{$Symbol};
74260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $RTid = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
74270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # add return type name
742862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Signature_M = $TypeInfo{$LibVersion}{$RTid}{"Name"}." ".$Signature_M;
74290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
74300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Signature_M;
74310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
74320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
7433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Signature($$)
7434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
743562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
743662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_Signature"}{$LibVersion}{$Symbol}) {
743762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_Signature"}{$LibVersion}{$Symbol};
7438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
743962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
74408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Signature, @Param_Types_FromUnmangledName) = ();
7441ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
744262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
744362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
7446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
7447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::";
7448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}) {
7449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Signature .= "~";
7450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
7451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
745362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"}) {
7454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $NameSpace."::".$ShortName;
7455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
745907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my ($Short, $Params) = split_Signature($tr_name{$MnglName});
746007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @Param_Types_FromUnmangledName = separate_Params($Params, 0, 1);
7461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
7463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
7464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Signature .= $MnglName;
7465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @ParamArray = ();
746762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
7468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Pos eq "");
747062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"};
7471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ParamTypeId);
747262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeName = $TypeInfo{$LibVersion}{$ParamTypeId}{"Name"};
7473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ParamTypeName) {
7474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamTypeName = $Param_Types_FromUnmangledName[$Pos];
7475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
7477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
74788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
74798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $ParamTypeName=~s/\b\Q$Typedef\E\b/$Base/g;
74808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
7481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7482177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ParamName = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"name"})
7483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
7484f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($ParamName eq "this"
7485f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $Symbol=~/\A(_Z|\?)/)
7486177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # do NOT show first hidded "this"-parameter
7487f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
7488177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
7489f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            push(@ParamArray, create_member_decl($ParamTypeName, $ParamName));
7490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ParamArray, $ParamTypeName);
7493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
749562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"}
749662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or $GlobalDataObject{$LibVersion}{$Symbol}) {
74978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " [data]";
7498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
750162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add [in-charge]
75038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " ".$ChargeLevel;
7504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
75058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " (".join(", ", @ParamArray).")";
750662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Const"}
750762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(V|)K/) {
75088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " const";
7509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
751062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Volatile"}
751162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(K|)V/) {
75128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " volatile";
7513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
751462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Static"}
751562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Symbol=~/\A(_Z|\?)/)
751674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # for static methods
75178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " [static]";
7518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $ShowRetVal
752162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and my $ReturnTId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"}) {
75228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= ":".$TypeInfo{$LibVersion}{$ReturnTId}{"Name"};
7523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
75258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
75278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"get_Signature"}{$LibVersion}{$Symbol} = $Signature);
7528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_member_decl($$)
7531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TName, $Member) = @_;
7533989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($TName=~/\([\*]+\)/)
7534989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TName=~s/\(([\*]+)\)/\($1$Member\)/;
7536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName;
7537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ArraySizes = ();
7541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($TName=~s/(\[[^\[\]]*\])\Z//) {
7542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ArraySizes, $1);
7543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName." ".$Member.join("", @ArraySizes);
7545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncType($)
7549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7550989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7551989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7552989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7553989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7554989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $Type = $LibInfo{$Version}{"info_type"}{$1})
7555989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
7556989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Type eq "method_type") {
7557989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Method";
7558989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7559989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($Type eq "function_type") {
7560989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Function";
7561989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7562989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
7563989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Other";
7564989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7565989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7566989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7568f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return "";
7569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncTypeId($)
7572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7573989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7574989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7575989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+)( |\Z)/) {
7576989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7577989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7579989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAnon($)
7583989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # "._N" or "$_N" in older GCC versions
7584989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($_[0] and $_[0]=~/(\.|\$)\_\d+|anon\-/);
7585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
75879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub formatName($$)
758862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # type name correction
75899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
75909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"formatName"}{$_[1]}{$_[0]};
759162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
759262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7593f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $_[0];
759462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
75959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] ne "S")
75969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
75979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/\A[ ]+//g;
75989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]+\Z//g;
75999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]{2,}/ /g;
76009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
76019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
76029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
760362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7604f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\bvolatile const\b/const volatile/g;
760562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7606f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
7607f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(short|long) int\b/$1/g;
760862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7609f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
761062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7611f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while($N=~s/>>/> >/g) {};
761262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] eq "S")
76149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
76159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($N, "operator")!=-1) {
76169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N=~s/\b(operator[ ]*)> >/$1>>/;
76179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
76189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
761962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
76209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
7621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_HeaderDeps($$)
7624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
7626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath or not $LibVersion);
7627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}) {
7628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %IncDir = ();
7631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_recursive_includes($AbsPath, $LibVersion);
7632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderPath (keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}}))
7633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HeaderPath);
7635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($MAIN_CPP_DIR and $HeaderPath=~/\A\Q$MAIN_CPP_DIR\E([\/\\]|\Z)/);
7636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Dir = get_dirname($HeaderPath);
7637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$HeaderPath}}))
7638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dep = $Dir;
7640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Prefix)
7641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($OSgroup eq "windows")
7643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # case insensitive seach on windows
7644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//ig) {
7645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
7646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($OSgroup eq "macos")
7649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # seach in frameworks
7650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
7652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($HeaderPath=~/(.+\.framework)\/Headers\/([^\/]+)/)
7653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# frameworks
7654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my ($HFramework, $HName) = ($1, $2);
7655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $Dep = $HFramework;
7656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
7658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# mismatch
7659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
7660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Linux, FreeBSD
7665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
7666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $Dep)
7669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nothing to include
7670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(is_default_include_dir($Dep))
7673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # included by the compiler
7674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_depth($Dep)==1)
7677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too short
7678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isLibcDir($Dep))
7681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # do NOT include /usr/include/{sys,bits}
7682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7684570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $IncDir{$Dep} = 1;
7685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath} = sortIncPaths([keys(%IncDir)], $LibVersion);
7688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub sortIncPaths($$)
7692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $LibVersion) = @_;
7694989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $ArrRef or $#{$ArrRef}<0) {
7695989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $ArrRef;
7696989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {$b cmp $a} @{$ArrRef};
7698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_depth($a)<=>get_depth($b)} @{$ArrRef};
7699989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    @{$ArrRef} = sort {sortDeps($b, $a, $LibVersion)} @{$ArrRef};
7700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ArrRef;
7701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7703989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub sortDeps($$$)
7704989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{
7705989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Header_Dependency{$_[2]}{$_[0]}
7706989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and not $Header_Dependency{$_[2]}{$_[1]}) {
7707989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return 1;
7708989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7709989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    elsif(not $Header_Dependency{$_[2]}{$_[0]}
7710989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and $Header_Dependency{$_[2]}{$_[1]}) {
7711989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return -1;
7712989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7713989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7714989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko}
7715989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
771674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub join_P($$)
771774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
771874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $S = "/";
771974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "windows") {
772074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $S = "\\";
772174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
772274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return join($S, @_);
7723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_namespace_additions($)
7726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $NameSpaces = $_[0];
7728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Additions, $AddNameSpaceId) = ("", 1);
7729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NS (sort {$a=~/_/ <=> $b=~/_/} sort {lc($a) cmp lc($b)} keys(%{$NameSpaces}))
7730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($SkipNameSpaces{$Version}{$NS});
7732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $NS or $NameSpaces->{$NS}==-1);
7733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/(\A|::)iterator(::|\Z)/i);
7734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/\A__/i);
7735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(($NS=~/\Astd::/ or $NS=~/\A(std|tr1|rel_ops|fcntl)\Z/) and not $STDCXX_TESTING);
77361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $NestedNameSpaces{$Version}{$NS} = 1; # for future use in reports
7737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypeDecl_Prefix, $TypeDecl_Suffix) = ();
7738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @NS_Parts = split(/::/, $NS);
7739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($#NS_Parts==-1);
7740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS_Parts[0]=~/\A(random|or)\Z/);
7741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $NS_Part (@NS_Parts)
7742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Prefix .= "namespace $NS_Part\{";
7744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Suffix .= "}";
7745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
774674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TypeDecl = $TypeDecl_Prefix."typedef int tmp_add_type_".$AddNameSpaceId.";".$TypeDecl_Suffix;
7747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FuncDecl = "$NS\:\:tmp_add_type_$AddNameSpaceId tmp_add_func_$AddNameSpaceId(){return 0;};";
7748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Additions.="  $TypeDecl\n  $FuncDecl\n";
7749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $AddNameSpaceId+=1;
7750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Additions;
7752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub path_format($$)
775574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
7756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Fmt) = @_;
775774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $Path=~s/[\/\\]+\.?\Z//g;
77581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Fmt eq "windows")
77591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
7760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\//\\/g;
7761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=lc($Path);
7762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
776374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
776474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # forward slash to pass into MinGW GCC
7765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\//g;
7766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub inc_opt($$)
7771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Style) = @_;
7773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Style eq "GCC")
77741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC options
7775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
77761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # to MinGW GCC
7777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I\"".path_format($Path, "unix")."\"";
7778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($OSgroup eq "macos"
7780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\.framework\Z/)
7781570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # to Apple's GCC
7782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-F".esc(get_dirname($Path));
7783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I".esc($Path);
7786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Style eq "CL") {
778962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "/I \"".$Path."\"";
7790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub platformSpecs($)
7795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
7797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = getArch($LibVersion);
7798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # options for GCCE compiler
7800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Symbian_Opts = map {$_=>1} (
7801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__GCCE__",
7802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DUNICODE",
7803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-fexceptions",
7804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SYMBIAN32__",
7805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_INTERWORK__",
7806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_UNICODE",
7807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_50__",
7808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_3X__",
7809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SERIES60_3X__",
7810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EPOC32__",
7811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM__",
7812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EABI__",
7813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_ARMV5__",
7814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SUPPORT_CPP_EXCEPTIONS__",
7815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-march=armv5t",
7816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mapcs",
7817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mthumb-interwork",
7818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DEKA2",
7819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSYMBIAN_ENABLE_SPLIT_HEADERS"
7820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        );
7821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%Symbian_Opts));
7822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows"
7824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i)
7825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add options to MinGW compiler
7826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to simulate the MSVC compiler
7827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MinGW_Opts = map {$_=>1} (
7828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_WIN32",
7829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_STDCALL_SUPPORTED",
7830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int64=\"long long\"",
7831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int32=int",
7832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int16=short",
7833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int8=char",
7834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__possibly_notnullterminated=\" \"",
7835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullterminated=\" \"",
7836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullnullterminated=\" \"",
7837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__w64=\" \"",
7838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr32=\" \"",
7839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr64=\" \"",
7840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=inline",
7841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__inline=inline",
7842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__uuidof(x)=IID()",
7843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__try=",
7844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__except(x)=",
7845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__declspec(x)=__attribute__((x))",
7846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__pragma(x)=",
7847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_inline=inline",
7848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=__inline",
7849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__stdcall=__attribute__((__stdcall__))",
7850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__cdecl=__attribute__((__cdecl__))",
7851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__fastcall=__attribute__((__fastcall__))",
7852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__thiscall=__attribute__((__thiscall__))",
7853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_stdcall=__attribute__((__stdcall__))",
7854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_cdecl=__attribute__((__cdecl__))",
7855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_fastcall=__attribute__((__fastcall__))",
7856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_thiscall=__attribute__((__thiscall__))",
7857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSHSTDAPI_(x)=x",
7858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_EXTENSIONS",
7859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSECURITY_WIN32",
7860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_VER=1500",
7861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_USE_DECLSPECS_FOR_SAL",
7862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__noop=\" \"",
7863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DDECLSPEC_DEPRECATED=\" \"",
7864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__builtin_alignof(x)=__alignof__(x)",
7865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSORTPP_PASS");
7866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch eq "x86") {
7867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IX86=300"}=1;
7868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "x86_64") {
7870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_AMD64=300"}=1;
7871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "ia64") {
7873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IA64=300"}=1;
7874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%MinGW_Opts));
7876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %C_Structure = map {$_=>1} (
7881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# FIXME: Can't separate union and struct data types before dumping,
7882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# so it sometimes cause compilation errors for unknown reason
7883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# when trying to declare TYPE* tmp_add_class_N
7884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This is a list of such structures + list of other C structures
7885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigval",
7886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigevent",
7887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaction",
7888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigvec",
7889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigstack",
7890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeval",
7891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timezone",
7892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rusage",
7893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rlimit",
7894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wait",
7895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "flock",
7896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat",
7897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat",
7898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat32",
7899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat32",
7900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat64",
7901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat64",
7902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stati64",
7903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "if_nameindex",
7904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "usb_device",
7905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaltstack",
7906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sysinfo",
7907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeLocale",
7908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tcp_debug",
7909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc_createerr",
791082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Other
7911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timespec",
7912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "random_data",
7913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "drand48_data",
7914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_marker",
7915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_FILE",
7916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lconv",
7917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched_param",
7918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tm",
7919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "itimerspec",
7920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_pthread_cleanup_buffer",
7921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fd_set",
792201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    "siginfo",
792382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "mallinfo",
7924570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "timex",
792574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sigcontext",
792674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ucontext",
792782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Mac
792882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_timex",
792982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_t",
793082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_category_t",
793182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_ro_t",
793282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_protocol_t",
793382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_message_ref_t",
793482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_super_message_ref_t",
793582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_t",
793682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_list_t"
7937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
7938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getCompileCmd($$$)
7940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Opt, $Inc) = @_;
7942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccCall = $GCC_PATH;
7943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Opt) {
7944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opt;
7945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $GccCall .= " -x ";
7947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos") {
7948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "objective-";
7949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7950f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
7951f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($EMERGENCY_MODE_48)
7952f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # workaround for GCC 4.8 (C only)
7953f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $GccCall .= "c++";
7954f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
7955f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    elsif(check_gcc($GCC_PATH, "4"))
7956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" header
7957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to obtain complete dump using GCC 4.0
7958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++-header";
7959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" source
7962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # GCC 3.3 cannot compile headers
7963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++";
7964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Opts = platformSpecs($Version))
7966d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # platform-specific options
7967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opts;
7968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # allow extra qualifications
7970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # and other nonconformant code
797101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -fpermissive";
797201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -w";
7973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($NoStdInc)
7974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc";
7976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc++";
7977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7978d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(my $Opts_GCC = getGCC_Opts($Version))
7979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined options
7980d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $GccCall .= " ".$Opts_GCC;
7981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7982a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $GccCall .= " \"$Path\"";
7983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Inc)
7984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # include paths
7985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Inc;
7986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccCall;
7988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
799001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub detectPreamble($$)
7991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
799201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Content, $LibVersion) = @_;
7993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeaderElems = (
7994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Types
7995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdio.h" => ["FILE", "va_list"],
7996850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "stddef.h" => ["NULL", "ptrdiff_t"],
79979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdint.h" => ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
79989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                       "int8_t", "int16_t", "int32_t", "int64_t"],
7999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "time.h" => ["time_t"],
8000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "sys/types.h" => ["ssize_t", "u_int32_t", "u_short", "u_char",
80019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                          "u_int", "off_t", "u_quad_t", "u_long", "mode_t"],
80029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "unistd.h" => ["gid_t", "uid_t", "socklen_t"],
8003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdbool.h" => ["_Bool"],
8004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "rpc/xdr.h" => ["bool_t"],
8005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "in_systm.h" => ["n_long", "n_short"],
8006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Fields
8007bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        "arpa/inet.h" => ["fw_src", "ip_src"],
8008bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        # Functions
80099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdlib.h" => ["free", "malloc", "size_t"],
8010850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "string.h" => ["memmove", "strcmp"]
8011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
8012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AutoPreamble = ();
8013850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (keys(%HeaderElems))
8014850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
8015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Elem (@{$HeaderElems{$_}}) {
80169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $AutoPreamble{$Elem} = $_;
8017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
801901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %Types = ();
802001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    while($Content=~s/error\:\s*(field\s*|)\W+(.+?)\W+//)
802101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # error: 'FILE' has not been declared
80229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Types{$2} = 1;
802301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
802401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%Types))
802501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
802601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my %AddHeaders = ();
802701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        foreach my $Type (keys(%Types))
802801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
802901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $Header = $AutoPreamble{$Type})
803001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
80319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Path = identifyHeader($Header, $LibVersion))
80329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
80339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(skipHeader($Path, $LibVersion)) {
80349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
80359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
80369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Path = path_format($Path, $OSgroup);
80379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Type"} = $Type;
80389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Header"} = $Header;
803901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
804001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
804101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
804201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(keys(%AddHeaders)) {
80439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return \%AddHeaders;
804401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
804501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
80469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return undef;
804701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
804801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
8049f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub checkCTags($)
8050f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko{
8051f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Path = $_[0];
8052f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $Path) {
8053f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8054f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8055570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $CTags = undef;
8056570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8057570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($OSgroup eq "bsd")
8058570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # use ectags on BSD
8059570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ectags");
8060570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CTags) {
8061570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            printMsg("WARNING", "can't find \'ectags\' program");
8062570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8063570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8064f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $CTags) {
8065570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ctags");
8066570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8067570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $CTags)
8068570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("WARNING", "can't find \'ctags\' program");
8070f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8071f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8072bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
807382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if($OSgroup ne "linux")
807482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    { # macos, freebsd, etc.
8075bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Info = `$CTags --version 2>\"$TMP_DIR/null\"`;
8076bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if($Info!~/exuberant/i)
8077bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
8078bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            printMsg("WARNING", "incompatible version of \'ctags\' program");
8079bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            return;
8080bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        }
8081bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    }
8082bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8083f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/ctags.txt";
8084bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    system("$CTags --c-kinds=pxn -f \"$Out\" \"$Path\" 2>\"$TMP_DIR/null\"");
8085f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($Debug) {
80869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        copy($Out, $DEBUG_PATH{$Version}."/ctags.txt");
8087f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8088f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    open(CTAGS, "<", $Out);
8089f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while(my $Line = <CTAGS>)
8090f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
8091f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        chomp($Line);
8092f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($Name, $Header, $Def, $Type, $Scpe) = split(/\t/, $Line);
80939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $Intrinsic_Keywords{$Name})
80949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # noise
80959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
80969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8097f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Type eq "n")
8098f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
80999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "class:")==0) {
81009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
81019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "struct:")==0) {
8103f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                next;
8104f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
81059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "namespace:")==0)
8106f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
81079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Scpe=~s/\Anamespace://) {
81089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Name = $Scpe."::".$Name;
81099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
81109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TUnit_NameSpaces{$Version}{$Name} = 1;
81129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "p")
81149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Funcs{$Version}{$Name} = 1;
81179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
81189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
81199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "x")
81209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
81219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
81229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Vars{$Version}{$Name} = 1;
8123f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
8124f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8125f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8126f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    close(CTAGS);
8127f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
8128f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
81298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub preChange($$)
813001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
81318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($HeaderPath, $IncStr) = @_;
81329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
81338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr);
81348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Content = undef;
813507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
8136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows"
8137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i
8138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $MinGWMode{$Version}!=-1)
8139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify headers to compile by MinGW
81408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
81428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/__asm\s*(\{[^{}]*?\}|[^{};]*)//g)
8145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # __asm { ... }
8146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/\s+(\/ \/.*?)\n/\n/g)
8149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # comments after preprocessing
8150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\W)(0x[a-f]+|\d+)(i|ui)(8|16|32|64)(\W)/$1$2$5/g)
8153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 0xffui8
8154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
81578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($MinGWMode{$Version}) {
8158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("INFO", "Using MinGW compatibility mode");
8159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
81618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
8162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($COMMON_LANGUAGE{$Version} eq "C" or $CheckHeadersOnly)
81638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $CppMode{$Version}!=-1 and not $CppCompat and not $CPP_HEADERS)
81641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # rename C++ keywords in C code
8165570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # disable this code by -cpp-compatible option
81668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
81688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_C = join("|", keys(%CppKeywords_C));
8171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_F = join("|", keys(%CppKeywords_F));
8172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_O = join("|", keys(%CppKeywords_O));
8173bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8174bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Detected = undef;
8175bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8176d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        while($Content=~s/(\A|\n[^\#\/\n][^\n]*?|\n)(\*\s*|\s+|\@|\,|\()($RegExp_C|$RegExp_F)(\s*([\,\)\;\.\[]|\-\>|\:\s*\d))/$1$2c99_$3$4/g)
8177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int new, int class, int (*new)(int));
8179d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko          # int foo(char template[], char*);
8180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # unsigned private: 8;
8181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # #pragma GCC visibility push(default)
818307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8184bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
8185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\s]|\w\s+)(?<!operator )(delete)(\s*\()/$1c99_$2$3/g)
8187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int delete(...);
8189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int explicit(...);
8190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void operator delete(...)
819207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8193bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
81958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)($RegExp_O)(\s*(\;|\:))/$1c99_$2$3/g)
8196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bool;
8198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # bool X;
8200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # return *this;
8201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # throw;
820207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8203bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)(operator)(\s*(\(\s*\)\s*[^\(\s]|\(\s*[^\)\s]))/$1c99_$2$3/g)
8206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator(...);
8208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator()(...);
821007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8211bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\(\,\s]\s*|\s+)(operator)(\s*(\,\s*[^\(\s]|\)))/$1c99_$2$3/g)
8214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator);
8216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator, int other);
8217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator,(...);
821907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8220bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\*\s*|\w\s+)(bool)(\s*(\,|\)))/$1c99_$2$3/g)
8223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(gboolean *bool);
8225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void setTabEnabled(int index, bool);
822707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8228bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\w)(\s*[^\w\(\,\s]\s*|\s+)(this|throw)(\s*[\,\)])/$1$2c99_$3$4/g)
8231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int* this);
8233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bar(int this);
82349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # int baz(int throw);
8235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
82369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # foo(X, this);
823707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8238bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
823907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
82408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(struct |extern )(template) /$1c99_$2 /g)
82418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # MATCH:
82428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # struct template {...};
82438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # extern template foo(...);
82448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CppMode{$Version} = 1;
82458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Detected = "$1$2" if(not defined $Detected);
82468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
824707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
824807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version} == 1)
824907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
8250bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            if($Debug)
8251bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            {
8252bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                $Detected=~s/\A\s+//g;
8253bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                printMsg("INFO", "Detected code: \"$Detected\"");
825407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
8255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
82569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
82579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # remove typedef enum NAME NAME;
82588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @FwdTypedefs = $Content=~/typedef\s+enum\s+(\w+)\s+(\w+);/g;
82599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $N = 0;
82609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while($N<=$#FwdTypedefs-1)
82619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
82629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $S = $FwdTypedefs[$N];
82639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($S eq $FwdTypedefs[$N+1])
82649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
82658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Content=~s/typedef\s+enum\s+\Q$S\E\s+\Q$S\E;//g;
8266fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CppMode{$Version} = 1;
8267fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8268fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Debug) {
8269fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    printMsg("INFO", "Detected code: \"typedef enum $S $S;\"");
8270fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
82719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
82729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N+=2;
82739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
82749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
82758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($CppMode{$Version}==1) {
827607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            printMsg("INFO", "Using C++ compatibility mode");
8277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
82798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
828007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1)
82828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
82838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $IPath = $TMP_DIR."/dump$Version.i";
82848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($IPath, $Content);
82858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $IPath;
82868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
82878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
82888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return undef;
82898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
82908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
82918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getDump()
82928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
82938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $GCC_PATH) {
82948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        exitStatus("Error", "internal error - GCC path is not set");
82958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
82968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
82978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my @Headers = keys(%{$Registered_Headers{$Version}});
82988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    @Headers = sort {int($Registered_Headers{$Version}{$a}{"Pos"})<=>int($Registered_Headers{$Version}{$b}{"Pos"})} @Headers;
82998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $IncludeString = getIncString(getIncPaths(@{$Include_Preamble{$Version}}, @Headers), "GCC");
83018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TmpHeaderPath = $TMP_DIR."/dump".$Version.".h";
83038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HeaderPath = $TmpHeaderPath;
83048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # write tmp-header
83068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    open(TMP_HEADER, ">", $TmpHeaderPath) || die ("can't open file \'$TmpHeaderPath\': $!\n");
83078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $AddDefines = $Descriptor{$Version}{"Defines"})
83088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $AddDefines=~s/\n\s+/\n  /g;
83108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "\n  // add defines\n  ".$AddDefines."\n";
83118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    print TMP_HEADER "\n  // add includes\n";
83138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@{$Include_Preamble{$Version}}) {
83148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@Headers)
83178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
83188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not grep {$HPath eq $_} (@{$Include_Preamble{$Version}})) {
83198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
83208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    close(TMP_HEADER);
83238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($IncludeString) {
83278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-string", $IncludeString);
83288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/recursive-includes", Dumper($RecursiveIncludes{$Version}));
83308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/direct-includes", Dumper($Header_Includes{$Version}));
83318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my @Redirects = keys(%{$Header_ErrorRedirect{$Version}}))
83338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
83348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $REDIR = "";
83358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $P1 (sort @Redirects) {
83368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $REDIR .= $P1.";".$Header_ErrorRedirect{$Version}{$P1}."\n";
83378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
83388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-redirect", $REDIR);
83398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
83408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$TargetHeaders{$Version}}))
83438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Target headers
83448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        addTargetHeaders($Version);
8345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8346850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8347850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
83488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %RecursiveIncludes = ();
83498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Include_Prefix = ();
83508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Includes = ();
83518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean cache
83538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"identifyHeader"});
83548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"detect_header_includes"});
83558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"selectSystemHeader"});
83568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # preprocessing stage
83588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Pre = callPreprocessor($TmpHeaderPath, $IncludeString, $Version);
83598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    checkPreprocessedUnit($Pre);
83608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
83628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
83638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/header-paths", join("\n", sort keys(%{$PreprocessedHeaders{$Version}})));
83648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean memory
83678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Include_Neighbors{$Version});
83688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($PreprocessedHeaders{$Version});
83698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++") {
83718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        checkCTags($Pre);
83728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
83738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $PrePath = preChange($TmpHeaderPath, $IncludeString))
83758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # try to correct the preprocessor output
83768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $HeaderPath = $PrePath;
83778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
8378850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
8380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add classes and namespaces to the dump
8381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CHdump = "-fdump-class-hierarchy -c";
838207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version}==1
8383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $MinGWMode{$Version}==1) {
8384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHdump .= " -fpreprocessed";
8385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $ClassHierarchyCmd = getCompileCmd($HeaderPath, $CHdump, $IncludeString);
8387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($TMP_DIR);
838862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($ClassHierarchyCmd." >null 2>&1");
8389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ClassDump = (cmd_find($TMP_DIR,"f","*.class",1))[0])
8391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Content = readFile($ClassDump);
8393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $ClassInfo (split(/\n\n/, $Content))
8394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ClassInfo=~/\AClass\s+(.+)\s*/i)
8396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
8397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $CName = $1;
8398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if($CName=~/\A(__|_objc_|_opaque_)/);
8399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TUnit_NameSpaces{$Version}{$CName} = -1;
8400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/\A[\w:]+\Z/)
8401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # classes
8402f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $TUnit_Classes{$Version}{$CName} = 1;
8403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/(\w[\w:]*)::/)
8405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # namespaces
8406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NS = $1;
8407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not defined $TUnit_NameSpaces{$Version}{$NS}) {
8408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TUnit_NameSpaces{$Version}{$NS} = 1;
8409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
8410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($ClassInfo=~/\AVtable\s+for\s+(.+)\n((.|\n)+)\Z/i)
8413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # read v-tables (advanced approach)
8414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($CName, $VTable) = ($1, $2);
8415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ClassVTable_Content{$Version}{$CName} = $VTable;
8416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8418a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $NS (keys(%{$AddNameSpaces{$Version}}))
8419a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            { # add user-defined namespaces
8420a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $TUnit_NameSpaces{$Version}{$NS} = 1;
8421a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
8422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Debug)
8423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # debug mode
8424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                mkpath($DEBUG_PATH{$Version});
84251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                copy($ClassDump, $DEBUG_PATH{$Version}."/class-hierarchy-dump.txt");
8426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($ClassDump);
8428f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8429f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
8430f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # add namespaces and classes
8431f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $NS_Add = get_namespace_additions($TUnit_NameSpaces{$Version}))
8432f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # GCC on all supported platforms does not include namespaces to the dump by default
84338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add namespaces\n".$NS_Add);
8434f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8435f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # some GCC versions don't include class methods to the TU dump by default
8436f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($AddClass, $ClassNum) = ("", 0);
8437570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $GCC_44 = check_gcc($GCC_PATH, "4.4"); # support for old GCC versions
8438f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        foreach my $CName (sort keys(%{$TUnit_Classes{$Version}}))
8439f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
8440f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($C_Structure{$CName});
8441f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if(not $STDCXX_TESTING and $CName=~/\Astd::/);
8442f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($SkipTypes{$Version}{$CName});
8443570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $Force and $GCC_44
8444570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $OSgroup eq "linux")
8445570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # optimization for linux with GCC >= 4.4
8446570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko              # disable this code by -force option
8447570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(index($CName, "::")!=-1)
8448570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # should be added by name space
844982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
845082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
845182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            }
845282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            else
845382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            {
845482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                if($CName=~/\A(.+)::[^:]+\Z/
845582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                and $TUnit_Classes{$Version}{$1})
845682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                { # classes inside other classes
845782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
845882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
8459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
84609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Funcs{$Version}{$CName})
84619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a function and type
84629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
84639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
84649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Vars{$Version}{$CName})
84659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a variable and type
84669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
84679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
8468f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $AddClass .= "  $CName* tmp_add_class_".($ClassNum++).";\n";
8469f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8470f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($AddClass) {
84718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add classes\n".$AddClass);
8472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "Temporary header file \'$TmpHeaderPath\' with the following content will be compiled to create GCC translation unit dump:\n".readFile($TmpHeaderPath)."\n");
8475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create TU dump
8476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TUdump = "-fdump-translation-unit -fkeep-inline-functions -c";
8477d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($UserLang eq "C") {
8478d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TUdump .= " -U__cplusplus -D_Bool=\"bool\"";
8479d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
848007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1) {
8482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TUdump .= " -fpreprocessed";
8483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
84848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $SyntaxTreeCmd = getCompileCmd($HeaderPath, $TUdump, $IncludeString);
8485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "The GCC parameters:\n  $SyntaxTreeCmd\n\n");
8486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($TMP_DIR);
8487a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($SyntaxTreeCmd." >\"$TMP_DIR/tu_errors\" 2>&1");
8488570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Errors = "";
8489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($?)
8490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # failed to compile, but the TU dump still can be created
8491570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors = readFile($TMP_DIR."/tu_errors"))
849201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to recompile
849301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko          # FIXME: handle other errors and try to recompile
849407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}==1
84952b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and index($Errors, "c99_")!=-1
84962b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            and not defined $CppIncompat)
849701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable c99 mode and try again
849807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $CppMode{$Version}=-1;
84992b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
85002b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                if($Debug)
85012b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                {
85022b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                    # printMsg("INFO", $Errors);
85032b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                }
85042b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
850507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                printMsg("INFO", "Disabling C++ compatibility mode");
850601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
850701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
850801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
8509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
851001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($AutoPreambleMode{$Version}!=-1
85119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            and my $AddHeaders = detectPreamble($Errors, $Version))
851201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # add auto preamble headers and try again
851301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $AutoPreambleMode{$Version}=-1;
85149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Headers = sort {$b cmp $a} keys(%{$AddHeaders}); # sys/types.h should be the first
8515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Num (0 .. $#Headers)
8516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
851701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Path = $Headers[$Num];
8518570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Path eq $_} (@{$Include_Preamble{$Version}}))
8519570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
8520570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        push_U($Include_Preamble{$Version}, $Path);
8521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        printMsg("INFO", "Add \'".$AddHeaders->{$Path}{"Header"}."\' preamble header for \'".$AddHeaders->{$Path}{"Type"}."\'");
8522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                resetLogging($Version);
8525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
8526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return getDump();
8527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
852801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($Cpp0xMode{$Version}!=-1
852901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and ($Errors=~/\Q-std=c++0x\E/
853001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or $Errors=~/is not a class or namespace/))
853101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # c++0x: enum class
8532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(check_gcc($GCC_PATH, "4.6"))
8533570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8534570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Cpp0xMode{$Version}=-1;
8535570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("INFO", "Enabling c++0x mode");
8536570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    resetLogging($Version);
8537570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $TMP_DIR = tempdir(CLEANUP=>1);
8538570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $CompilerOptions{$Version} .= " -std=c++0x";
8539570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    return getDump();
8540570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8541570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else {
8542570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("WARNING", "Probably c++0x construction detected");
8543570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8544570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
854501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
854601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($MinGWMode{$Version}==1)
854701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable MinGW mode and try again
854801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $MinGWMode{$Version}=-1;
854901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
855001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
855101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
855201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
855301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, $Errors);
8554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
855501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        else {
855601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, "$!: $?\n");
8557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "some errors occurred when compiling headers");
8559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printErrorLog($Version);
8560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMPILE_ERRORS = $ERROR_CODE{"Compile_Error"};
8561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeLog($Version, "\n"); # new line
8562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($ORIG_DIR);
8564f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    unlink($TmpHeaderPath);
85658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    unlink($HeaderPath);
8566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my @TUs = cmd_find($TMP_DIR,"f","*.tu",1)) {
8568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $TUs[0];
8569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    else
8571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $Msg = "can't compile header(s)";
8573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors=~/error trying to exec \W+cc1plus\W+/) {
8574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Msg .= "\nDid you install G++?";
8575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Cannot_Compile", $Msg);
8577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmd_file($)
8581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $CmdPath = get_CmdPath("file")) {
8585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return `$CmdPath -b \"$Path\"`;
8586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncString($$)
8591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $Style) = @_;
8593989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "" if(not $ArrRef or $#{$ArrRef}<0);
8594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $String = "";
8595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@{$ArrRef}) {
8596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $String .= " ".inc_opt($_, $Style);
8597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $String;
8599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncPaths(@)
8602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @HeaderPaths = @_;
8604570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my @IncPaths = @{$Add_Include_Paths{$Version}};
8605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($INC_PATH_AUTODETECT{$Version})
8606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # auto-detecting dependencies
8607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Includes = ();
8608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $HPath (@HeaderPaths)
8609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Dir (get_HeaderDeps($HPath, $Version))
8611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip_Include_Paths{$Version}{$Dir}) {
8613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
8614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8615a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if($SystemRoot)
8616a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
8617a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    if($Skip_Include_Paths{$Version}{$SystemRoot.$Dir}) {
8618a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                        next;
8619a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
8620a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
8621570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Includes{$Dir} = 1;
8622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dir (@{sortIncPaths([keys(%Includes)], $Version)}) {
8625570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@IncPaths, $Dir);
8626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined paths
8630570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @IncPaths = @{$Include_Paths{$Version}};
8631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \@IncPaths;
8633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub push_U($@)
8636570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{ # push unique
8637570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $Array = shift @_)
8638570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8639570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(@_)
8640570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
8641570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Exist = map {$_=>1} @{$Array};
8642570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Elem (@_)
8643570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
8644570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not defined $Exist{$Elem})
8645570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8646570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push(@{$Array}, $Elem);
8647570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Exist{$Elem} = 1;
8648570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8649570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
8650570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8651570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
8653570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub callPreprocessor($$$)
8655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Inc, $LibVersion) = @_;
8657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
8658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $IncludeString=$Inc;
8659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Inc) {
8660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IncludeString = getIncString(getIncPaths($Path), "GCC");
8661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = getCompileCmd($Path, "-dD -E", $IncludeString);
8663f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/preprocessed.h";
8664a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($Cmd." >\"$Out\" 2>\"$TMP_DIR/null\"");
8665dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $Out;
8666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
86684b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub cmd_find($;$$$$)
8669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # native "find" is much faster than File::Find (~6x)
8670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # also the File::Find doesn't support --maxdepth N option
8671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # so using the cross-platform wrapper for the native one
8672570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Path, $Type, $Name, $MaxDepth, $UseRegex) = @_;
8673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -e $Path);
8674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
86786fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Cmd = "dir \"$Path\" /B /O";
8679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth!=1) {
8680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /S";
8681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /AD";
8684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
868574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        elsif($Type eq "f") {
868674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Cmd .= " /A-D";
868774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
8688570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, `$Cmd 2>\"$TMP_DIR/null\"`);
8689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Name)
86908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
86918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $UseRegex)
86928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # FIXME: how to search file names in MS shell?
86938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko              # wildcard to regexp
8694570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Name=~s/\*/.*/g;
86958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Name='\A'.$Name.'\Z';
8696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
86978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/i } @Files;
8698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @AbsPaths = ();
8700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $File (@Files)
8701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not is_abs($File)) {
870374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $File = join_P($Path, $File);
8704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type eq "f" and not -f $File)
8706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # skip dirs
8707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
8708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, path_format($File, $OSgroup));
8710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, $Path);
8713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @AbsPaths;
8715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FindCmd = get_CmdPath("find");
8719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $FindCmd) {
8720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find a \"find\" command");
8721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path and -l $Path
8724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path!~/\/\Z/)
8725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for directories that are symlinks
8726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path.="/";
8727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $FindCmd." \"$Path\"";
8729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth) {
8730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -maxdepth $MaxDepth";
8731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type) {
8733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -type $Type";
8734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8735570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and not $UseRegex)
8736570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # wildcards
8737570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cmd .= " -name \"$Name\"";
8738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
87399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Res = `$Cmd 2>\"$TMP_DIR/null\"`;
87408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($? and $!) {
87419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            printMsg("ERROR", "problem with \'find\' utility ($?): $!");
87429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8743570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, $Res);
8744570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and $UseRegex)
8745570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # regex
87468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/ } @Files;
8747570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
87484b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return @Files;
8749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unpackDump($)
8753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = get_abs_path($Path);
8757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = path_format($Path, $OSgroup);
8758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $FileName) = separate_path($Path);
8759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UnpackDir = $TMP_DIR."/unpack";
8760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    rmtree($UnpackDir);
8761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    mkpath($UnpackDir);
8762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($FileName=~s/\Q.zip\E\Z//g)
8763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UnzipCmd = get_CmdPath("unzip");
8765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UnzipCmd) {
8766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"unzip\" command");
8767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($UnpackDir);
876974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        system("$UnzipCmd \"$Path\" >\"$TMP_DIR/null\"");
8770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?) {
877174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
877474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Contents = cmd_find($UnpackDir, "f");
8775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Contents) {
8776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\'");
8777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
877874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return $Contents[0];
8779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8780fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    elsif($FileName=~s/\Q.tar.gz\E(\.\w+|)\Z//g)
8781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8782b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko      # *.tar.gz.amd64 (dh & cdbs)
8783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
8784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -xvzf option is not implemented in tar.exe (2003)
8785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # use "gzip.exe -k -d -f" + "tar.exe -xvf" instead
8786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
8791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $GzipCmd) {
8792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\" command");
8793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
8795a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system("$GzipCmd -k -d -f \"$Path\""); # keep input files (-k)
8796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
8797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
879974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvf \"$Dir\\$FileName.tar\" >\"$TMP_DIR/null\"");
8800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
880174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
8804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Dir."/".$FileName.".tar");
880574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
880974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
881274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # Unix, Mac
8813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
881874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvzf \"$Path\" >\"$TMP_DIR/null\"");
8819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
882074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
882374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
882774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
8828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createArchive($$)
8833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $To) = @_;
88355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $To) {
88365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $To = ".";
88375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
8838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path or not -e $Path
8839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -d $To) {
8840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
8841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($From, $Name) = separate_path($Path);
8843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ZipCmd = get_CmdPath("zip");
8846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ZipCmd) {
8847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"zip\"");
8848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = $To."/".$Name.".zip";
8850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($To);
8852a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        system("$ZipCmd -j \"$Name.zip\" \"$Path\" >\"$TMP_DIR/null\"");
8853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "zip")
8855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Pkg;
8861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TarCmd = get_CmdPath("tar");
8865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TarCmd) {
8866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"tar\"");
8867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $GzipCmd = get_CmdPath("gzip");
8869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GzipCmd) {
8870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"gzip\"");
8871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = abs_path($To)."/".$Name.".tar.gz";
8873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
8874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($From);
8875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system($TarCmd, "-czf", $Pkg, $Name);
8876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
8877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "tar")
8878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
8879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
8880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
8883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $To."/".$Name.".tar.gz";
8884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header_file($)
8888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.($HEADER_EXT)\Z/i) {
8890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $_[0];
8891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_not_header($)
8896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.\w+\Z/
8898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $_[0]!~/\.($HEADER_EXT)\Z/i) {
8899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
8900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header($$$)
8905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $UserDefined, $LibVersion) = @_;
8907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(-d $Header);
8908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header) {
8909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Header = get_abs_path($Header);
8910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Header))
8914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # incorrect absolute path
8915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
891762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HPath = identifyHeader($Header, $LibVersion)) {
8918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header = $HPath;
8919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # can't find header
8922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
8923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header=~/\.\w+\Z/)
8926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # have an extension
8927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return is_header_file($Header);
8928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserDefined==2)
8932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified on the command line
8933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(cmd_file($Header)!~/HTML|XML/i) {
8934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($UserDefined)
8938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified in the XML-descriptor
8939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # header file without an extension
8940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Header;
8941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
8943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8944570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Header, "/include/")!=-1
8945850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or cmd_file($Header)=~/C[\+]*\s+program/i)
8946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # !~/HTML|XML|shared|dynamic/i
8947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
8948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
8952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
89541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addTargetHeaders($)
8955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
8957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $RegHeader (keys(%{$Registered_Headers{$LibVersion}}))
8958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegDir = get_dirname($RegHeader);
896046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        $TargetHeaders{$LibVersion}{get_filename($RegHeader)} = 1;
89619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
89629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $INC_PATH_AUTODETECT{$LibVersion}) {
89639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            detect_recursive_includes($RegHeader, $LibVersion);
89649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
89659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
8966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $RecInc (keys(%{$RecursiveIncludes{$LibVersion}{$RegHeader}}))
8967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($RecInc);
8969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(familiarDirs($RegDir, $Dir)
8971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $RecursiveIncludes{$LibVersion}{$RegHeader}{$RecInc}!=1)
8972850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # in the same directory or included by #include "..."
897346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($RecInc)} = 1;
8974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub familiarDirs($$)
8980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
8981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($D1, $D2) = @_;
8982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($D1 eq $D2) {
8983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
8984fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
8985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
8986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U1 = index($D1, "/usr/");
8987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U2 = index($D2, "/usr/");
8988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
8989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U1==0 and $U2!=0) {
8990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
8991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
8992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
8993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U2==0 and $U1!=0) {
8994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
8995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
8996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
8997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($D2, $D1."/")==0) {
8998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 1;
8999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /usr/include/DIR
9002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /home/user/DIR
9003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $DL = get_depth($D1);
9005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs1 = ($D1);
9007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while($DL - get_depth($D1)<=2
9008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and get_depth($D1)>=4
9009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D1=~s/[\/\\]+[^\/\\]*?\Z//) {
9010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs1, $D1);
9011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs2 = ($D2);
9014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while(get_depth($D2)>=4
9015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D2=~s/[\/\\]+[^\/\\]*?\Z//) {
9016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs2, $D2);
9017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $P1 (@Dirs1)
9020fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
9021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $P2 (@Dirs2)
9022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($P1 eq $P2) {
9025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
9026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9028fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
9030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
9031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readHeaders($)
9033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Version = $_[0];
9035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "checking header(s) ".$Descriptor{$Version}{"Version"}." ...");
9036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DumpPath = getDump();
9037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
9038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug mode
9039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
90401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        copy($DumpPath, $DEBUG_PATH{$Version}."/translation-unit-dump.txt");
9041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getInfo($DumpPath);
9043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub prepareTypes($)
9046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
904862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.0"))
9049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # type names have been corrected in ACC 1.22 (dump 2.0 format)
905162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
9052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
905362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
905462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TName=~/\A(\w+)::(\w+)/) {
905562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($P1, $P2) = ($1, $2);
905662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($P1 eq $P2) {
905762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A$P1:\:$P1(\W)/$P1$1/;
905862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
905962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
906062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A(\w+:\:)$P2:\:$P2(\W)/$1$P2$2/;
9061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
906362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Name"} = $TName;
9064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
906662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.5"))
9067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V < 2.5: array size == "number of elements"
9069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V >= 2.5: array size in bytes
907062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9072f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %Type = get_PureType($TypeId, $TypeInfo{$LibVersion});
907362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Type{"Type"} eq "Array")
9074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
907501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Size = $Type{"Size"})
907662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[N]
9077f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %Base = get_OneStep_BaseType($Type{"Tid"}, $TypeInfo{$LibVersion});
907801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $Size *= $Base{"Size"};
907901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = "$Size";
908062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
908162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
908262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[] is a pointer
908362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $WORD_SIZE{$LibVersion};
9084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V2 = ($LibVersion==1)?2:1;
908962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.7"))
9090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # size of "method ptr" corrected in 2.7
909262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9094f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
909562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($PureType{"Type"} eq "MethodPtr")
9096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
909762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type = get_Type($TypeId, $LibVersion);
909862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TypeId_2 = getTypeIdByName($PureType{"Name"}, $V2);
909962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type2 = get_Type($TypeId_2, $V2);
910062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Type{"Size"} ne $Type2{"Size"}) {
910162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $Type2{"Size"};
9102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
91081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub prepareSymbols($)
9109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
91111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
91121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
91131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # check if input is valid
9114ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
91151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
91161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CheckHeadersOnly) {
91171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty (".$Descriptor{$LibVersion}{"Version"}.")");
91181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            else {
91201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection (".$Descriptor{$LibVersion}{"Version"}.")");
91211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
91221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
91231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
91241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Remangle = 0;
912662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.10")
912762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.10"))
9128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
9129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Remangle = 1;
9130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly)
9132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different languages
9133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserLang)
9134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --lang=LANG for both versions
9135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(($UsedDump{1}{"V"} and $UserLang ne $UsedDump{1}{"L"})
9136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or ($UsedDump{2}{"V"} and $UserLang ne $UsedDump{2}{"L"}))
9137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($UserLang eq "C++")
9139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remangle symbols
9140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = 1;
9141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($UserLang eq "C")
9143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remove mangling
9144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = -1;
9145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
914962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
91501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (sort {int($b)<=>int($a)} keys(%{$SymbolInfo{$LibVersion}}))
9151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order: D0, D1, D2, D0 (artificial, GCC < 4.5), C1, C2
915262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.13"))
91530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
91540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
91550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
91560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                foreach my $P (keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}}))
91570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
91580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $TypeId = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"type"};
91590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $DVal = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"};
916062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
91610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $DVal and $DVal ne "")
91620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
91630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($TName eq "char") {
91640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = chr($DVal);
91650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
91660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif($TName eq "bool") {
91670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = $DVal?"true":"false";
91680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
91690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
91700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
91710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
91720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
91731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
9174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
91751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
91761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})
9177082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko            and $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
9178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old GCC < 4.5: skip artificial ~dtor(int __in_chrg)
9179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # + support for old ABI dumps
9180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
9181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
91831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9184850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
91851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassID = $SymbolInfo{$LibVersion}{$InfoId}{"Class"};
9186850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
9187989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
91881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $SRemangle = 0;
918962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.12")
919062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.12"))
91911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # support for old ABI dumps
9192850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($ShortName eq "operator>>")
9193850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9194850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
9195850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of operator>>
9196850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9197850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
91981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9199850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
9200850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9201850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
9202850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                and isConstType($Return, $LibVersion) and $MnglName!~/L\d+$ShortName/)
9203850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of const global data
9204850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # some global data is not mangled in the TU dump: qt_sine_table (Qt 4.8)
9205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and incorrectly mangled by old ACC versions
9206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
92081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
92091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
92105c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $CheckHeadersOnly)
92115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # support for old ABI dumps
92125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not checkDump(1, "2.17")
92135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not checkDump(2, "2.17"))
92145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
92155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
92165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                {
92175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
92185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    {
92195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        if(link_symbol($ShortName, $LibVersion, "-Deps"))
92205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        {
92215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $MnglName = $ShortName;
92225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
92235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        }
92245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    }
92255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
92265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
92275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
92281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Remangle==1 or $SRemangle==1)
9229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old ABI dumps: some symbols are not mangled in old dumps
9230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # mangle both sets of symbols (old and new)
9231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # NOTE: remangling all symbols by the same mangler
9232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(V|)K/)
9233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Const" attribute
92351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Const"} = 1;
9236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(K|)V/)
9238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Volatile" attribute
92401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Volatile"} = 1;
9241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
92421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(($ClassID and $MnglName!~/\A(_Z|\?)/)
92431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and $CheckHeadersOnly)
92441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and not link_symbol($MnglName, $LibVersion, "-Deps")))
92451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # support for old ABI dumps, GCC >= 4.0
92461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko              # remangling all manually mangled symbols
92471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($MnglName = mangle_symbol($InfoId, $LibVersion, "GCC"))
9248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
92491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
9250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MangledNames{$LibVersion}{$MnglName} = 1;
9251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Remangle==-1)
9255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # remove mangling
9256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MnglName = "";
92571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = "";
9258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $MnglName) {
9260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$MnglName}{"MnglName"})
9263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # NOTE: global data may enter here twice
92641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$MnglName}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
92651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
9266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
926762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.6"))
9268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps
9269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # add "Volatile" attribute
9270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/_Z(K|)V/) {
9271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompleteSignature{$LibVersion}{$MnglName}{"Volatile"}=1;
9272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # symbol and its symlink have same signatures
9275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymVer{$LibVersion}{$MnglName}) {
92761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$MnglName}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9278850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Alias = $CompleteSignature{$LibVersion}{$MnglName}{"Alias"})
9280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
9281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Alias}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SymVer{$LibVersion}{$Alias}) {
9283fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$Alias}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9284fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
9285fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9286fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9287850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
92881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId});
9289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" or $OSgroup eq "windows") {
9291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        translateSymbols(keys(%{$CompleteSignature{$LibVersion}}), $LibVersion);
9292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
9294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
9295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addExtension($LibVersion);
9296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9297850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9298850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
9299850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    delete($SymbolInfo{$LibVersion});
9300850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9301850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
9302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect allocable classes with public exported constructors
9303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or classes with auto-generated or inline-only constructors
93049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and other temp info
9305850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
9306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
930762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
9308850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"}
9309850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"})
9310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Class() { ... } will not be exported
9311850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9313850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly or link_symbol($Symbol, $LibVersion, "-Deps")) {
9314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AllocableClass{$LibVersion}{$ClassName} = 1;
9315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9318850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all imported class methods
9320850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Binary"))
9321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9322850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly)
9323850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
9324850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if(not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
9325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        or $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
9326850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        { # all symbols except non-virtual inline
9327850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9328850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        }
9329850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9330850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    else {
9331850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
933462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Source")) {
9335850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $ClassMethods{"Source"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
93381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $ClassNames{$LibVersion}{$ClassName} = 1;
9339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $RetId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
9341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
934262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Base = get_BaseType($RetId, $LibVersion);
9343850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $Base{"Type"}
9344850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and $Base{"Type"}=~/Struct|Class/)
9345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
934662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Name = $TypeInfo{$LibVersion}{$Base{"Tid"}}{"Name"};
9347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Name=~/<([^<>\s]+)>/)
9348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $Tid = getTypeIdByName($1, $LibVersion)) {
9350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ReturnedClass{$LibVersion}{$Tid} = 1;
9351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
9354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ReturnedClass{$LibVersion}{$Base{"Tid"}} = 1;
9355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9358850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Num (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
9359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9360850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $PId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Num}{"type"};
936162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(get_PLevel($PId, $LibVersion)>=1)
9362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
936362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my %Base = get_BaseType($PId, $LibVersion))
9364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
93651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if($Base{"Type"}=~/Struct|Class/)
93661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    {
9367850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ParamClass{$LibVersion}{$Base{"Tid"}}{$Symbol} = 1;
93681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        foreach my $SubId (get_sub_classes($Base{"Tid"}, $LibVersion, 1))
93691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # mark all derived classes
9370850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ParamClass{$LibVersion}{$SubId}{$Symbol} = 1;
93711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        }
9372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
93769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
93779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # mapping {short name => symbols}
93789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Func_ShortName{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"ShortName"}}{$Symbol} = 1;
9379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9380dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $MnglName (keys(%VTableClass))
938174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # reconstruct attributes of v-tables
93829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($MnglName, "_ZTV")==0)
9383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9384dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $ClassName = $VTableClass{$MnglName})
9385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
938674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
938774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
938862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Header"} = $TypeInfo{$LibVersion}{$ClassId}{"Header"};
938974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Class"} = $ClassId;
9390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
93941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
93951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # types
939662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
93971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
939862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"})
93991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
940062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"}) {
940162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
94021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
940362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"Base"})
94041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
940562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
940662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"Base"}}))
94071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                {
940862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BName = $TypeInfo{$LibVersion}{$Bid}{"Name"}) {
940962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $ClassNames{$LibVersion}{$BName} = 1;
94101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    }
94111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
94121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
94131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
94141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
9415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9417177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getFirst($$)
9418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9419177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Tid) {
9421177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return $Tid;
9422177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9423177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9424177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"})
9425177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9426177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TName_Tid{$LibVersion}{$Name}) {
9427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $TName_Tid{$LibVersion}{$Name};
9428177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9429177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9430177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Tid;
9432177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_SymbolUsage($$$)
9435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9436177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($InfoId, $UsedType, $LibVersion) = @_;
9437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9438177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %FuncInfo = %{$SymbolInfo{$LibVersion}{$InfoId}};
9439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $RTid = getFirst($FuncInfo{"Return"}, $LibVersion))
9440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($RTid, $UsedType, $LibVersion);
9442177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Return"} = $RTid;
9443177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9444177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $FCid = getFirst($FuncInfo{"Class"}, $LibVersion))
9445177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9446177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($FCid, $UsedType, $LibVersion);
9447177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Class"} = $FCid;
9448177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9449177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."*const", $LibVersion))
9450177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer
9451177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId, $UsedType, $LibVersion);
9452177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9453177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId_C = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."const*const", $LibVersion))
9454177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer (const method)
9455177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId_C, $UsedType, $LibVersion);
9456177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9457177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $PPos (keys(%{$FuncInfo{"Param"}}))
9459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9460177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $PTid = getFirst($FuncInfo{"Param"}{$PPos}{"type"}, $LibVersion))
9461177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9462177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($PTid, $UsedType, $LibVersion);
9463177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $FuncInfo{"Param"}{$PPos}{"type"} = $PTid;
9464177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9466177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $TPos (keys(%{$FuncInfo{"TParam"}}))
9467177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9468177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $TPName = $FuncInfo{"TParam"}{$TPos}{"name"};
9469177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($TTid, $UsedType, $LibVersion);
9471177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9472177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9473177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9474177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9475177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_TypeUsage($$$)
9476177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9477177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($TypeId, $UsedType, $LibVersion) = @_;
947862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $TypeId) {
9479177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9480989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9481177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($UsedType->{$TypeId})
9482989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # already registered
9483177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9484989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9485177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
948662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TInfo = get_Type($TypeId, $LibVersion);
9487850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TInfo{"Type"})
9488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9489177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $NS = $TInfo{"NameSpace"})
9490177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9491177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $NSTid = $TName_Tid{$LibVersion}{$NS}) {
9492177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($NSTid, $UsedType, $LibVersion);
9493177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9494177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9495177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9496177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TInfo{"Type"}=~/\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\Z/)
9497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9498177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9499850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"}=~/\A(Struct|Class)\Z/)
9500989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9501177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $BaseId (keys(%{$TInfo{"Base"}})) {
9502177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($BaseId, $UsedType, $LibVersion);
9503989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9504850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $TPos (keys(%{$TInfo{"TParam"}}))
9505850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
9506850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    my $TPName = $TInfo{"TParam"}{$TPos}{"name"};
9507850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9508177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($TTid, $UsedType, $LibVersion);
9509850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9510850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
95111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9512850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            foreach my $Memb_Pos (keys(%{$TInfo{"Memb"}}))
9513989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9514177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $MTid = getFirst($TInfo{"Memb"}{$Memb_Pos}{"type"}, $LibVersion))
9515177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9516177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($MTid, $UsedType, $LibVersion);
9517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TInfo{"Memb"}{$Memb_Pos}{"type"} = $MTid;
9518989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
95191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9520850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"} eq "FuncPtr"
9521177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "MethodPtr"
9522177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "Func")
9523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9524850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9526989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $PPos (keys(%{$TInfo{"Param"}}))
9528989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
9529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $PTid = $TInfo{"Param"}{$PPos}{"type"}) {
9530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($PTid, $UsedType, $LibVersion);
9531989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
9532989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "FieldPtr")
9535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "MethodPtr")
9544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9550850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($TInfo{"Type"}=~/\A(Const|ConstVolatile|Volatile|Pointer|Ref|Restrict|Array|Typedef)\Z/)
9551989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
9552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $BTid = getFirst($TInfo{"BaseType"}, $LibVersion))
9554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($BTid, $UsedType, $LibVersion);
9556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $BTid;
9557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
95581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
9559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # Intrinsic, TemplateParam, TypeName, SizeOf, etc.
9561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
95621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
95631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
95641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
95651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9566850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub selectSymbol($$$$)
956735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko{ # select symbol to check or to dump
9568850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Symbol, $SInfo, $Level, $LibVersion) = @_;
9569850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
957035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($Level eq "Dump")
957135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    {
957235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($SInfo->{"Virt"} or $SInfo->{"PureVirt"})
957335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        { # TODO: check if this symbol is from
957435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko          # base classes of other target symbols
957535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            return 1;
957635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
957735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    }
957835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko
9579850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $STDCXX_TESTING and $Symbol=~/\A(_ZS|_ZNS|_ZNKS)/)
9580850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # stdc++ interfaces
9581850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return 0;
95820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
9583850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9584850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Target = 0;
9585850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Header = $SInfo->{"Header"}) {
9586850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Target = (is_target_header($Header, 1) or is_target_header($Header, 2));
9587850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
95888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtendedCheck)
95898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
9590c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        if(index($Symbol, "external_func_")==0) {
95918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Target = 1;
95928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
95938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
9594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckHeadersOnly or $Level eq "Source")
9595850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9596850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Target)
9597850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9598850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Dump")
9599850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # dumped
9600850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($BinaryOnly)
96010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
9602850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(not $SInfo->{"InLine"} or $SInfo->{"Data"}) {
96030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        return 1;
96040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
96050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
9606850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else {
9607850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9608850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
96090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
9610850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Source")
9611850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9612850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9613850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9614850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Binary")
9615850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9616850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SInfo->{"InLine"} or $SInfo->{"Data"}
9617850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $SInfo->{"Virt"} or $SInfo->{"PureVirt"}) {
9618850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9619850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
9623850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
9624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # library is available
9625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(link_symbol($Symbol, $LibVersion, "-Deps"))
9626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # exported symbols
9627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
9628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Dump")
9630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # dumped
963135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            if($BinaryOnly)
963235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            {
963335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($SInfo->{"Data"})
963435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                {
963535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    if($Target) {
963635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                        return 1;
963735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    }
9638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
964035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            else
964135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # SrcBin
9642850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9643850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9644850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9645850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9646850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9647850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Source")
9648850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
964901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"} or $SInfo->{"InLine"}
9650ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($SInfo, $LibVersion))
965135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # skip LOCAL symbols
965235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($Target) {
965335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    return 1;
965435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                }
96550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
96560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
9657850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Binary")
9658850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
9659850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"})
9660850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9661850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9662850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9663850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9664850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9665850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
96660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
96670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
96680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
96690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
9670850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub cleanDump($)
9671850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # clean data
9672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
96731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
9674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9675177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}}))
9676177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9677177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9678177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9679177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
96801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9681177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $MnglName)
9682177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
96831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9686850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
9687177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ShortName)
9688177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9689989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9690989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
9691989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9692850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($MnglName eq $ShortName)
9693850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # remove duplicate data
96941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"MnglName"});
9695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9696850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})) {
9697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"Param"});
9698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
969901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}})) {
970001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"TParam"});
970101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9702f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId}{"Type"});
9703850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
970462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
9705850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9706177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}}))
9707177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9708177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9709177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9710177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
971101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid}{"Tid"});
971262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Attr ("Header", "Line", "Size", "NameSpace")
9713850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
971462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $TypeInfo{$LibVersion}{$Tid}{$Attr}) {
971562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{$Attr});
9716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
971801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}{"TParam"}})) {
971901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TParam"});
972001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9721850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
972262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
972362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
972428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub pickType($$)
972562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
972662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
97279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
97289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $Dupl = $TypeTypedef{$LibVersion}{$Tid})
97299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
97309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$Dupl})
97319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
97329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Dupl}{"Name"} eq $TypeInfo{$LibVersion}{$Tid}{"Name"})
97339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # duplicate
97349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return 0;
97359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
97369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
97379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
97389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
973928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"};
974028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
974128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isBuiltIn($THeader)) {
974228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
974328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
974428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
974528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/) {
974628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
974728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
974828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
974928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(isAnon($TypeInfo{$LibVersion}{$Tid}{"Name"})) {
975028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
975128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
975228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
975328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(selfTypedef($Tid, $LibVersion)) {
975428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
975528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
975628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
975728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(not isTargetType($Tid, $LibVersion)) {
975828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 0;
975928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
976028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
976128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 0;
976228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko}
976328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
976428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenkosub isTargetType($$)
976528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko{
976628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
976728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
976828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($TypeInfo{$LibVersion}{$Tid}{"Type"}!~/Class|Struct|Union|Enum|Typedef/)
976928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    { # derived
977028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        return 1;
977128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
977228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
977362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"})
9774850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
977528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(not is_target_header($THeader, $LibVersion))
977628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        { # from target headers
977728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
9778850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9779850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
978028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
978128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    return 1;
9782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9784177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub remove_Unused($$)
9785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # remove unused data types from the ABI dump
9786850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($LibVersion, $Kind) = @_;
9787177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9788177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %UsedType = ();
9789177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9790177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $InfoId (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}}))
9791850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9792177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_SymbolUsage($InfoId, \%UsedType, $LibVersion);
9793177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9794177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9795177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9796177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9797177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9798177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9799177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9800177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9801177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extended")
9802177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
980328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            if(pickType($Tid, $LibVersion))
9804177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9805177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Tree = ();
9806177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($Tid, \%Tree, $LibVersion);
9807177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9808177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Tmpl = 0;
9809177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (sort {int($a)<=>int($b)} keys(%Tree))
9810177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9811177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9812177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9813177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
9814177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Tmpl = 1;
9815177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        last;
9816177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9817177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9818177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not $Tmpl)
9819177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9820177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%Tree)) {
9821177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $UsedType{$_} = 1;
9822177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9823177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9825177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9826177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9827177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9828177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %Delete = ();
9829177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9830177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9831177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove unused types
9832177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9833177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9834177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9835989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9836177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9837177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extra")
9838850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9839177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Tree = ();
9840177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($Tid, \%Tree, $LibVersion);
9841177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9842177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%Tree))
9843177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9844177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9845177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9846177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9847177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Delete{$Tid} = 1;
9848177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last;
9849850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9851989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9852177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9853177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9854177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            # remove type
9855177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9856177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9857177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9858177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9859177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Kind eq "Extra")
9860177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove duplicates
9861177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($UsedType{$Tid})
9864177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # All & Extended
9865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"};
9869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9870177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName_Tid{$LibVersion}{$Name} ne $Tid) {
9871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid});
9872989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
9873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9874177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9875177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9876177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (keys(%Delete))
9877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid});
9879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_Completeness($$)
9883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9884177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Info, $LibVersion) = @_;
9885177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9886177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # data types
9887177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Memb"})
9888177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9889177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Memb"}}))
9890850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9891177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Memb"}{$Pos}{"type"}) {
9892177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Memb"}{$Pos}{"type"}, $LibVersion);
9893850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Base"})
989762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
9898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Bid (keys(%{$Info->{"Base"}})) {
9899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_TypeInfo($Bid, $LibVersion);
990062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
9901177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9902177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"BaseType"}) {
9903177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"BaseType"}, $LibVersion);
9904177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9905177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"TParam"})
9906177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9907177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"TParam"}}))
9908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $TName = $Info->{"TParam"}{$Pos}{"name"};
9910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\A\(.+\)(true|false|\d.*)\Z/) {
9911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName eq "_BoolType") {
9914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9916177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\Asizeof\(/) {
9917177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
9918177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9919177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Tid = $TName_Tid{$LibVersion}{$TName}) {
9920177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Tid, $LibVersion);
9921177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9922177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            else
9923177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9924177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $Debug) {
9925177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    printMsg("WARNING", "missed type $TName");
9926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # symbols
9932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Param"})
9933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Param"}}))
9935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Param"}{$Pos}{"type"}) {
9937177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Param"}{$Pos}{"type"}, $LibVersion);
9938177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
993962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
994062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
9941177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Return"}) {
9942177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Return"}, $LibVersion);
9943177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9944177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Class"}) {
9945177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Class"}, $LibVersion);
9946177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9947177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9948177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9949177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_TypeInfo($$)
9950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9951177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9952850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $CheckedTypeInfo{$LibVersion}{$Tid}) {
9954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $CheckedTypeInfo{$LibVersion}{$Tid} = 1;
9957177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$Tid})
9959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9960177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $TypeInfo{$LibVersion}{$Tid}{"Name"}) {
9961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            printMsg("ERROR", "missed type name ($Tid)");
9962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9963177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_Completeness($TypeInfo{$LibVersion}{$Tid}, $LibVersion);
9964177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9965177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else {
9966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        printMsg("ERROR", "missed type id $Tid");
9967177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9968850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9969850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
997062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selfTypedef($$)
9971850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
997262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
997362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = get_Type($TypeId, $LibVersion);
9974850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type{"Type"} eq "Typedef")
9975dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
9976f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base = get_OneStep_BaseType($TypeId, $TypeInfo{$LibVersion});
9977850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base{"Type"}=~/Class|Struct/)
9978850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9979850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Type{"Name"} eq $Base{"Name"}) {
9980850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9981850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9982850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Type{"Name"}=~/::(\w+)\Z/)
9983850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9984850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Type{"Name"} eq $Base{"Name"}."::".$1)
9985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # QPointer<QWidget>::QPointer
9986850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9987850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9989dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
9990dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
9991850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
9992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
99941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addExtension($)
9995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
99961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
99978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
999928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(pickType($Tid, $LibVersion))
10000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
100018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$Tid}{"Name"};
100028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $TName=~s/\A(struct|union|class|enum) //;
100038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Symbol = "external_func_".$TName;
1000462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1000562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Symbol}} = (
1000662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Header" => "extended.h",
1000762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "ShortName" => $Symbol,
1000862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "MnglName" => $Symbol,
1000962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param" => { 0 => { "type"=>$Tid, "name"=>"p1" } }
1001062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1001162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
100128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ExtendedSymbols{$Symbol} = 1;
100138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
100148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Source"}{$Symbol} = 1;
10015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
100178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $ExtendedSymbols{"external_func_0"} = 1;
100188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Binary"}{"external_func_0"} = 1;
100198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Source"}{"external_func_0"} = 1;
10020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod($$$)
10023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1002562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $BaseClass_Id (keys(%{$TypeInfo{$LibVersion}{$ClassId}{"Base"}}))
10026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VirtMethodInClass = findMethod_Class($VirtFunc, $BaseClass_Id, $LibVersion)) {
10028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInClass;
10029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $VirtMethodInBaseClasses = findMethod($VirtFunc, $BaseClass_Id, $LibVersion)) {
10031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInBaseClasses;
10032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod_Class($$$)
10038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1004062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
10041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not defined $VirtualTable{$LibVersion}{$ClassName});
10042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetSuffix = get_symbol_suffix($VirtFunc, 1);
10043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetShortName = $CompleteSignature{$LibVersion}{$VirtFunc}{"ShortName"};
10044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for interface with the same parameters suffix (overridden)
10046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetSuffix eq get_symbol_suffix($Candidate, 1))
10047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10048e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"Destructor"})
10049e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10050989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Candidate}{"Destructor"})
10051989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($VirtFunc=~/D0E/ and $Candidate=~/D0E/)
10053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D1E/ and $Candidate=~/D1E/)
10054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D2E/ and $Candidate=~/D2E/)) {
10055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return $Candidate;
10056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10059e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            else
10060e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TargetShortName eq $CompleteSignature{$LibVersion}{$Candidate}{"ShortName"}) {
10062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
10063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
100701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub registerVTable($)
10071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
100721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
100731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
10074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
100751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Virt"}
100761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{$LibVersion}{$Symbol}{"PureVirt"})
10077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1007862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"Class"}}{"Name"};
10079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $STDCXX_TESTING and $ClassName=~/\A(std::|__cxxabi)/);
100801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}
100811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Symbol=~/D2E/)
10082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual D2-destructors are marked as "virt" in the dump
10083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # virtual D2-destructors are NOT marked as "virt" in the dump
10084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # both destructors are not presented in the v-table
10085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
10086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
100871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
10088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $VirtualTable{$LibVersion}{$ClassName}{$MnglName} = 1;
10089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub registerOverriding($)
10094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Classes = keys(%{$VirtualTable{$LibVersion}});
10097850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Classes = sort {int($TName_Tid{$LibVersion}{$a})<=>int($TName_Tid{$LibVersion}{$b})} @Classes;
10098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (@Classes)
10099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $VirtFunc (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
101021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"PureVirt"})
101031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # pure virtuals
101041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                next;
101051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
101061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $ClassId = $TName_Tid{$LibVersion}{$ClassName};
101071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Overridden = findMethod($VirtFunc, $ClassId, $LibVersion))
10108850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10109850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Overridden}{"Virt"}
10110850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $CompleteSignature{$LibVersion}{$Overridden}{"PureVirt"})
10111850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # both overridden virtual methods
10112850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and implemented pure virtual methods
10113850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$VirtFunc}{"Override"} = $Overridden;
10114850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $OverriddenMethods{$LibVersion}{$Overridden}{$VirtFunc} = 1;
10115850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    delete($VirtualTable{$LibVersion}{$ClassName}{$VirtFunc}); # remove from v-table model
10116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not keys(%{$VirtualTable{$LibVersion}{$ClassName}})) {
10120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($VirtualTable{$LibVersion}{$ClassName});
10121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setVirtFuncPositions($)
10126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{$LibVersion}}))
10129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10130fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my ($Num, $Rel) = (1, 0);
10131fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10132fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Funcs = sort keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10134fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UsedDump{$LibVersion}{"DWARF"}) {
10135fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @Funcs;
10136fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10137fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
10138fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @Funcs;
10139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10140fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $VirtFunc (@Funcs)
10141fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
10142fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10143fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $CompleteSignature{$LibVersion}{$VirtFunc}{"VirtPos"};
10144fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10145fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10146fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $Num++;
10147fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10148fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10149fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # set relative positions
10150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(defined $VirtualTable{1}{$ClassName} and defined $VirtualTable{1}{$ClassName}{$VirtFunc}
10151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and defined $VirtualTable{2}{$ClassName} and defined $VirtualTable{2}{$ClassName}{$VirtFunc})
10152fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # relative position excluding added and removed virtual functions
10153fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $CompleteSignature{1}{$VirtFunc}{"Override"}
10154fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $CompleteSignature{2}{$VirtFunc}{"Override"}) {
10155fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $CompleteSignature{$LibVersion}{$VirtFunc}{"RelPos"} = $Rel++;
10156fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
10157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
101611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{$LibVersion}}))
10162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $AbsNum = 1;
101641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $VirtFunc (getVTable_Model($TName_Tid{$LibVersion}{$ClassName}, $LibVersion)) {
10165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $VirtualTable_Model{$LibVersion}{$ClassName}{$VirtFunc} = $AbsNum++;
10166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_classes($$$)
10171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
10173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $Class_SubClasses{$LibVersion}{$ClassId});
10174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Subs = ();
10175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubId (keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
101771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
101781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubSubId (get_sub_classes($SubId, $LibVersion, $Recursive)) {
10180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Subs, $SubSubId);
10181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Subs, $SubId);
10184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Subs;
10186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_base_classes($$$)
10189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
1019162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %ClassType = get_Type($ClassId, $LibVersion);
10192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $ClassType{"Base"});
10193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = ();
10194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (sort {int($ClassType{"Base"}{$a}{"pos"})<=>int($ClassType{"Base"}{$b}{"pos"})}
10195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    keys(%{$ClassType{"Base"}}))
10196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
101971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
101981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubBaseId (get_base_classes($BaseId, $LibVersion, $Recursive)) {
10200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Bases, $SubBaseId);
10201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Bases, $BaseId);
10204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Bases;
10206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
102081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Model($$)
102091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # return an ordered list of v-table elements
10210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Elements = ();
10213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases, $ClassId)
10214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1021562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10216850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10217850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName})
10218850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10219fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my @VFuncs = keys(%{$VirtualTable{$LibVersion}{$BName}});
10220fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @VFuncs;
10222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10223fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @VFuncs;
10225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $VFunc (@VFuncs) {
10227850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    push(@Elements, $VFunc);
10228850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10229850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Elements;
10233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVShift($$)
10236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VShift = 0;
10240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1024262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10243850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10244850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName}) {
10245850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $VShift+=keys(%{$VirtualTable{$LibVersion}{$BName}});
10246850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VShift;
10250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getShift($$)
10253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 0);
10256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Shift = 0;
10257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1025962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Size = $TypeInfo{$LibVersion}{$BaseId}{"Size"})
10260dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
10261dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Size!=1)
10262dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # not empty base class
10263dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $Shift+=$Size;
10264dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
10265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Shift;
10268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
102701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Size($$)
102711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # number of v-table elements
10272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
102731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Size = 0;
102741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # three approaches
102751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
102761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # real size
102771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(my %VTable = getVTable_Real($ClassName, $LibVersion)) {
102781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%VTable);
102791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
102811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
102821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # shared library symbol size
102831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Size = getSymbolSize($ClassVTable{$ClassName}, $LibVersion)) {
102841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size /= $WORD_SIZE{$LibVersion};
102851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
102871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
102881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # model size
102891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $VirtualTable_Model{$LibVersion}{$ClassName}) {
102901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%{$VirtualTable_Model{$LibVersion}{$ClassName}}) + 2;
102911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
102921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
102931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Size;
10294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCopyingClass($$)
10297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1029962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return $TypeInfo{$LibVersion}{$TypeId}{"Copied"};
10300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLeafClass($$)
10303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (not keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}));
10306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub havePubFields($)
10309dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check structured type for public fields
10310dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return isAccessible($_[0], {}, 0, -1);
10311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAccessible($$$$)
10314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check interval in structured type for public fields
10315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $Skip, $Start, $End) = @_;
10316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($End==-1) {
10318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $End = keys(%{$TypePtr->{"Memb"}})-1;
10319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10320a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko    foreach my $MemPos (sort {int($a)<=>int($b)} keys(%{$TypePtr->{"Memb"}}))
10321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Skip and $Skip->{$MemPos})
10323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip removed/added fields
10324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($MemPos)>=$Start and int($MemPos)<=$End)
10327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isPublic($TypePtr, $MemPos)) {
10329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return ($MemPos+1);
10330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isReserved($)
10337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # reserved fields == private
10338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MName = $_[0];
10339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/reserved|padding|f_spare/i) {
10340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10342d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($MName=~/\A[_]*(spare|pad|unused|dummy)[_\d]*\Z/i) {
10343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/(pad\d+)/i) {
10346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isPublic($$)
10352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $FieldPos) = @_;
10354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
10356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
10357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypePtr->{"Memb"}{$FieldPos}{"access"})
10358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by name in C language
10359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: add other methods to detect private members
10360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
10361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MName=~/priv|abidata|parent_object/i)
10362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C-styled private data
10363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(lc($MName) eq "abi")
10366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # ABI information/reserved field
10367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isReserved($MName))
10370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # reserved fields
10371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypePtr->{"Memb"}{$FieldPos}{"access"} ne "private")
10376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by access in C++ language
10377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Real($$)
103831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
103841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
103851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
103861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
1038762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type = get_Type($ClassId, $LibVersion);
103881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Type{"VTable"}) {
103891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return %{$Type{"VTable"}};
103901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
103911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
103921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ();
103931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
103941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
103951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables($)
103961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
103971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ClassName = $_[0];
103981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Res = cmpVTables_Real($ClassName, 1);
103991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Res==-1) {
104001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Res = cmpVTables_Model($ClassName);
104011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Res;
104031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
104041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
10405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVTables_Model($)
10406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ClassName = $_[0];
104081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $Symbol (keys(%{$VirtualTable_Model{1}{$ClassName}}))
10409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
104101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol}) {
10411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
10412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables_Real($$)
10418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $Strong) = @_;
104201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"cmpVTables_Real"}{$Strong}{$ClassName}) {
104211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"cmpVTables_Real"}{$Strong}{$ClassName};
10422dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
104231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_Old = getVTable_Real($ClassName, 1);
104241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_New = getVTable_Real($ClassName, 2);
104251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not %VTable_Old or not %VTable_New)
10426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old ABI dumps
104271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = -1);
10428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Indexes = map {$_=>1} (keys(%VTable_Old), keys(%VTable_New));
10430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Offset (sort {int($a)<=>int($b)} keys(%Indexes))
10431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
104321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_Old{$Offset})
10433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 < v-table v.2
104341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = $Strong);
10435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
104361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry1 = $VTable_Old{$Offset};
104371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_New{$Offset})
10438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 > v-table v.2
104391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = ($Strong or $Entry1!~/__cxa_pure_virtual/));
10440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
104411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry2 = $VTable_New{$Offset};
10442ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry1 = simpleVEntry($Entry1);
10444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry2 = simpleVEntry($Entry2);
10445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Entry1 ne $Entry2)
10446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register as changed
10447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry1=~/::([^:]+)\Z/)
10448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
10449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $M1 = $1;
10450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Entry2=~/::([^:]+)\Z/)
10451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $M2 = $1;
10453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($M1 eq $M2)
10454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # overridden
10455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10459989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(differentDumps("G"))
10460989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
10461989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Entry1=~/\A\-(0x|\d+)/ and $Entry2=~/\A\-(0x|\d+)/)
10462989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10463989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.6.1: -0x00000000000000010
10464989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.7.0: -16
10465989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    next;
10466989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
10467989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
104681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 1);
10469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 0);
10472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVTables($)
10475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # merging v-tables without diagnostics
104761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
10477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{1}}))
10478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
104791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($VTableChanged_M{$ClassName})
10480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # already registered
10481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
104831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(cmpVTables_Real($ClassName, 0)==1)
10484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
104851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
10486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (@Affected)
10487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
104881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Virtual_Table_Changed_Unknown"}{$ClassName}}=(
10489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$ClassName,
10490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$ClassName);
10491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeBases($)
10497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
104981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
104991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{1}}))
10500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added and removed virtual functions
105011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId);
10503dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{2}{$ClassName})
10504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{2}{$ClassName}}))
10506dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
105071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{1}{$ClassName}
105081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{1}{$ClassName}{$Symbol})
10509dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # added to v-table
105101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{1}{$Symbol}
105111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{1}{$Symbol}{"Virt"})
105121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.1
105131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10514dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
105151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $AddedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10519dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{1}{$ClassName})
10520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
105211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{1}{$ClassName}}))
10522dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
105231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{2}{$ClassName}
105241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{2}{$ClassName}{$Symbol})
10525dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # removed from v-table
105261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$Symbol}
105271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{2}{$Symbol}{"Virt"})
105281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.2
105291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10530dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
105311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $RemovedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
105351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
105361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
1053762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Class_Type = get_Type($ClassId, 1);
105381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$ClassName}}))
105391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # check replacements, including pure virtual methods
105401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $AddedPos = $VirtualTable{2}{$ClassName}{$AddedVFunc};
105411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$ClassName}}))
10542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
105431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $RemovedPos = $VirtualTable{1}{$ClassName}{$RemovedVFunc};
105441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($AddedPos==$RemovedPos)
105451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
105461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$AddedVFunc} = $RemovedVFunc;
105471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$RemovedVFunc} = $AddedVFunc;
105481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        last; # other methods will be reported as "added" or "removed"
10549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
105511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $RemovedVFunc = $VirtualReplacement{$AddedVFunc})
10552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
105531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(lc($AddedVFunc) eq lc($RemovedVFunc))
105541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # skip: DomUi => DomUI parameter (Qt 4.2.3 to 4.3.0)
10555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
105571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ProblemType = "Virtual_Replacement";
105581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @Affected = ($RemovedVFunc);
105591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
105601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # pure methods
105611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not isUsedClass($ClassId, 1, $Level))
105621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # not a parameter of some exported method
105631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
105641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
105651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemType = "Pure_Virtual_Replacement";
105669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
105679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        # affected all methods (both virtual and non-virtual ones)
105689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
105699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        push(@Affected, keys(%{$OverriddenMethods{1}{$RemovedVFunc}}));
105701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
105719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $VTableChanged_M{$ClassName}=1;
105721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $AffectedInt (@Affected)
105731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
105741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$AffectedInt}{"PureVirt"})
105751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # affected exported methods only
105761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
105771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
105789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(not symbolFilter($AffectedInt, 1, "Affected", $Level)) {
105799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
105809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
105811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$AffectedInt}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
105821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$Class_Type{"Name"},
105831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2),
105841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>get_Signature($RemovedVFunc, 1));
105851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
10586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1059062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.0")
1059162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.0"))
105921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # support for old ABI dumps
105939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # "Base" attribute introduced in ACC 1.22 (ABI dump 2.0 format)
10594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (sort keys(%{$ClassNames{1}}))
10597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_Old = $TName_Tid{1}{$ClassName};
10599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId_Old);
10600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isCreatable($ClassId_Old, 1))
10601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip classes without public constructors (including auto-generated)
10602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # example: class has only a private exported or private inline constructor
10603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ClassName=~/>/)
10606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip affected template instances
10607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1060962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_Old = get_Type($ClassId_Old, 1);
106101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_New = $TName_Tid{2}{$ClassName};
10611850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $ClassId_New) {
10612850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
10613850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
1061462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_New = get_Type($ClassId_New, 2);
10615850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Class_New{"Type"}!~/Class|Struct/)
10616850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # became typedef
10617850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Binary") {
10618850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                next;
10619850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Source")
10621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10622f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Class_New = get_PureType($ClassId_New, $TypeInfo{2});
10623850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Class_New{"Type"}!~/Class|Struct/) {
10624850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
10625850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10626850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ClassId_New = $Class_New{"Tid"};
10627850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
10629ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10630ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $Class_New{"Size"} or not $Class_Old{"Size"})
10631ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # incomplete info in the ABI dump
10632ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
10633ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
10634ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10635ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
10636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_Old = sort {$Class_Old{"Base"}{$a}{"pos"}<=>$Class_Old{"Base"}{$b}{"pos"}} keys(%{$Class_Old{"Base"}});
10637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_New = sort {$Class_New{"Base"}{$a}{"pos"}<=>$Class_New{"Base"}{$b}{"pos"}} keys(%{$Class_New{"Base"}});
10638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10639f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_Old = map {$TypeInfo{1}{$_}{"Name"} => uncover_typedefs($TypeInfo{1}{$_}{"Name"}, 1)} @Bases_Old;
10640f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_New = map {$TypeInfo{2}{$_}{"Name"} => uncover_typedefs($TypeInfo{2}{$_}{"Name"}, 2)} @Bases_New;
10641f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($BNum1, $BNum2) = (1, 1);
10643f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @Bases_Old;
10644f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @Bases_New;
1064574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_Old = map {get_ShortClass($_, 1) => 1} @Bases_Old;
1064674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_New = map {get_ShortClass($_, 2) => 1} @Bases_New;
10647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_Old = getShift($ClassId_Old, 1);
10648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_New = getShift($ClassId_New, 2);
10649f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BaseId_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @Bases_New;
10650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Added, $Removed) = (0, 0);
10651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_Old = ();
10652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_Old)
10653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1065462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10655f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_New{$Tr_Old{$BaseName}}) {
10656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_Old, $BaseId);
10657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10658f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_New{$Tr_Old{$BaseName}}
1065974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_New{get_ShortClass($BaseId, 1)})
10660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # removed base
10661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Removed_Base_Class";
106631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
106641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
106651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
106661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
106671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
106681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
106691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
106701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
106711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
106721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
106741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{1}{$BaseName}})
106751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
106761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
106771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
106781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
106811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10684f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10685f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10686f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10687f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10688f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10689f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
106949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
106959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
106969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
106971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Removed+=1;
10705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_New = ();
10708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_New)
10709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1071062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{2}{$BaseId}{"Name"};
10711f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_Old{$Tr_New{$BaseName}}) {
10712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_New, $BaseId);
10713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10714f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_Old{$Tr_New{$BaseName}}
1071574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_Old{get_ShortClass($BaseId, 2)})
10716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # added base
10717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Added_Base_Class";
107191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
107201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
107211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
107221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
107231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
107241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
107251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
107271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
107281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{2}{$BaseName}})
107311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
107321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
107331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
107341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10740f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10741f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10742f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10743f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10744f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10745f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
107529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
107531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Added+=1;
10761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
107631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
107641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
107651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            ($BNum1, $BNum2) = (1, 1);
10766f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @StableBases_Old;
10767f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @StableBases_New;
107681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $BaseId (@Bases_Old)
10769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1077062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10771f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(my $NewPos = $BaseRelPos_New{$Tr_Old{$BaseName}})
107721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
10773f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $BaseNewId = $BaseId_New{$Tr_Old{$BaseName}};
10774f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $OldPos = $BaseRelPos_Old{$Tr_Old{$BaseName}};
107751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($NewPos!=$OldPos)
107761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed position of the base class
107771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
107781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
107799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
107819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
107821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Position"}{"this"}}=(
107831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
107841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName,
107851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$OldPos-1,
107861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Value"=>$NewPos-1  );
107871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Class_Old{"Base"}{$BaseId}{"virtual"}
107901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and not $Class_New{"Base"}{$BaseNewId}{"virtual"})
107911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became non-virtual base
107921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
107931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
107949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
107959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
107969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
107971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Non_Virtually_Inherited"}{"this->".$BaseName}}=(
107981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
107991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $Class_Old{"Base"}{$BaseId}{"virtual"}
108031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Class_New{"Base"}{$BaseNewId}{"virtual"})
108041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became virtual base
108051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Virtually_Inherited"}{"this->".$BaseName}}=(
108111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
108121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
108131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
108171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # detect size changes in base classes
108181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Shift_Old!=$Shift_New)
108191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # size of allocable class
108201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $BaseId (@StableBases_Old)
108211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # search for changed base
1082262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %BaseType = get_Type($BaseId, 1);
1082362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Size_Old = $TypeInfo{1}{$BaseId}{"Size"};
10824f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $Size_New = $TypeInfo{2}{$BaseId_New{$Tr_Old{$BaseType{"Name"}}}}{"Size"};
108251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Size_Old ne $Size_New
108261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Size_Old and $Size_New)
10827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
10828d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        my $ProblemType = undef;
108291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isCopyingClass($BaseId, 1)) {
108301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Size_Of_Copying_Class";
10831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
108321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($AllocableClass{1}{$BaseType{"Name"}})
108331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
108341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Size_New>$Size_Old)
108351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # increased size
108361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Increased";
108371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
108381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            else
108391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # decreased size
108401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Decreased";
108411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                if(not havePubFields(\%Class_Old))
108421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # affected class has no public members
108431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
108441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
108471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next if(not $ProblemType);
108481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
108491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # base class size changes affecting current class
108509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
108529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
108531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{$ProblemType}{"this->".$BaseType{"Name"}}}=(
108541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$BaseType{"Name"},
108551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseType{"Name"},
108561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Size"=>$Size_Old*$BYTE_SIZE,
108571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Size"=>$Size_New*$BYTE_SIZE  );
108581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10862f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(defined $VirtualTable_Model{1}{$ClassName}
108631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            and cmpVTables_Real($ClassName, 1)==1
10864f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and my @VFunctions = keys(%{$VirtualTable_Model{1}{$ClassName}}))
108651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # compare virtual tables size in base classes
108661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_Old = getVShift($ClassId_Old, 1);
108671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_New = getVShift($ClassId_New, 2);
108681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($VShift_Old ne $VShift_New)
108691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # changes in the base class or changes in the list of base classes
108701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_Old = get_base_classes($ClassId_Old, 1, 1);
108711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_New = get_base_classes($ClassId_New, 2, 1);
108721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    ($BNum1, $BNum2) = (1, 1);
10873f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %StableBase = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @AllBases_New;
108741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $BaseId (@AllBases_Old)
10875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1087662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %BaseType = get_Type($BaseId, 1);
10877f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(not $StableBase{$Tr_Old{$BaseType{"Name"}}})
108781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # lost base
108791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
10880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
108811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_Old = getVTable_Size($BaseType{"Name"}, 1);
108821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_New = getVTable_Size($BaseType{"Name"}, 2);
108831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($VSize_Old!=$VSize_New)
10884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
10885850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            foreach my $Symbol (@VFunctions)
10886f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            { # TODO: affected non-virtual methods?
10887f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol})
108881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # Removed_Virtual_Method, will be registered in mergeVirtualTables()
108891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
10890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
10891850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($VirtualTable_Model{2}{$ClassName}{$Symbol}-$VirtualTable_Model{1}{$ClassName}{$Symbol}==0)
108921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # skip interfaces that have not changed the absolute virtual position
108931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
108941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
10895850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
10896850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
108971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
108981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$BaseType{"Name"}} = 1;
108991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$ClassName} = 1;
109001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$AddedInt_Virt{$Level}{$BaseType{"Name"}}}))
109011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: added virtual functions
109021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
109031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Added_Virtual_Method";
109041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{2}{$VirtFunc}{"PureVirt"}) {
109051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Added_Pure_Virtual_Method";
109061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
10907850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 2)}}=(
109081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
109091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 2)  );
109101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
109111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$RemovedInt_Virt{$Level}{$BaseType{"Name"}}}))
109121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: removed virtual functions
109131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
109141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Removed_Virtual_Method";
109151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{1}{$VirtFunc}{"PureVirt"}) {
109161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Removed_Pure_Virtual_Method";
109171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
10918850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 1)}}=(
109191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
109201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 1)  );
10921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
10922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
10923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
10924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCreatable($$)
10932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
1093462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($AllocableClass{$LibVersion}{$TypeInfo{$LibVersion}{$ClassId}{"Name"}}
10935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isCopyingClass($ClassId, $LibVersion)) {
10936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Fix for incomplete data: if this class has
10940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # a base class then it should also has a constructor
10941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReturnedClass{$LibVersion}{$ClassId})
10944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # returned by some method of this class
10945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or any other class
10946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
109511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isUsedClass($$$)
10952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
109531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($ClassId, $LibVersion, $Level) = @_;
10954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$ParamClass{$LibVersion}{$ClassId}}))
10955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # parameter of some exported method
10956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1095862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1095962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(keys(%{$ClassMethods{$Level}{$LibVersion}{$CName}}))
10960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # method from target class
10961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
109661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVirtualTables($$)
10967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # check for changes in the virtual table
109681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Interface, $Level) = @_;
109691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # affected methods:
10970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - virtual
10971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - pure-virtual
10972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - non-virtual
10973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompleteSignature{1}{$Interface}{"Data"})
10974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # global data is not affected
10975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Class_Id = $CompleteSignature{1}{$Interface}{"Class"};
109781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Class_Id) {
109791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
109801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
1098162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{1}{$Class_Id}{"Name"};
109821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(cmpVTables_Real($CName, 1)==0)
109831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # no changes
109841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
109851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
109861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $CheckedTypes{$Level}{$CName} = 1;
109871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
109881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Binary-level
109891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Interface}{"PureVirt"}
109901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not isUsedClass($Class_Id, 1, $Level))
109911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # pure virtuals should not be affected
109920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # if there are no exported methods using this class
109931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return;
109941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
109950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
109960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach my $Func (keys(%{$VirtualTable{1}{$CName}}))
109970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
109980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $VirtualTable{2}{$CName}{$Func}
109990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and defined $CompleteSignature{2}{$Func})
110000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
110010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(not $CompleteSignature{1}{$Func}{"PureVirt"}
110020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$Func}{"PureVirt"})
110030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became pure virtual
110040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Pure"}{$tr_name{$Func}}}=(
110050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
110060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
110070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
110080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
110090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($CompleteSignature{1}{$Func}{"PureVirt"}
110100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and not $CompleteSignature{2}{$Func}{"PureVirt"})
110110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became non-pure virtual
110120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Non_Pure"}{$tr_name{$Func}}}=(
110130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
110140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
110150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
110160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
110170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
110180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
110190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Level eq "Binary")
110200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # Binary-level
110211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        # check virtual table structure
110221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
110231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
110241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
110251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$AddedVFunc});
110261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $VPos_Added = $VirtualTable{2}{$CName}{$AddedVFunc};
110271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
110281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # pure virtual methods affect all others (virtual and non-virtual)
110291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$CName,
11031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
110321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
11033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(not defined $VirtualTable{1}{$CName}
11035dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            or $VPos_Added>keys(%{$VirtualTable{1}{$CName}}))
110361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # added virtual function at the end of v-table
110371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not keys(%{$VirtualTable_Model{1}{$CName}}))
110381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # became polymorphous class, added v-table pointer
110391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{"Added_First_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$CName,
11041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>get_Signature($AddedVFunc, 2)  );
110421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $VTableChanged_M{$CName} = 1;
11043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
110461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_Old = getVTable_Size($CName, 1);
110471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_New = getVTable_Size($CName, 2);
110489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next if($VSize_Old==$VSize_New); # exception: register as removed and added virtual method
110491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(isCopyingClass($Class_Id, 1))
110501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # class has no constructors and v-table will be copied by applications, this may affect all methods
110511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
110521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
110531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Copying_Class";
110541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
110551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
110561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
110571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
110581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
110591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
110601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    else
110611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
110621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
110631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
110641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Allocable_Class";
110651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
110661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
110671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
110681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
110691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
110701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
110711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
110721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
110731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
110741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
110751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
11076dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName}
11077dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and defined $VirtualTable{2}{$CName})
110781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
11079dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11080dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11081fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11082dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Added<=$VPos_Old and $VPos_Old!=$VPos_New)
110831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11084dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11085dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11086dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11087850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11088850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
110899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11090850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11091850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11092dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11093dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11094dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{"Added_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11095dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11096dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($AddedVFunc, 2)  );
1109762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
110981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
111021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
111031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                # safe
111041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
111061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
111081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$RemovedVFunc});
111091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($RemovedVFunc eq $Interface
111101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
111111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # This case is for removed virtual methods
111129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # implemented in both versions of a library
111131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
111141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$VirtualTable_Model{2}{$CName}}))
111161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # became non-polymorphous class, removed v-table pointer
111171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Last_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
111181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
111191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
111201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
111221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
111231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
11124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11125dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName} and defined $VirtualTable{2}{$CName})
11126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11127dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(not defined $VirtualTable{1}{$CName}{$Interface}) {
11128dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        next;
11129dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11130dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = -1;
11131dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{2}{$CName}{$Interface})
111321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11133dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11134dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11135dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    else
11136dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11137dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if($Interface ne $RemovedVFunc) {
111381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
111391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11140dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11141dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Removed = $VirtualTable{1}{$CName}{$RemovedVFunc};
11142dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11143dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Removed<=$VPos_Old and $VPos_Old!=$VPos_New)
11144dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11146dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11147dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11148850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11149850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
111509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11151850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11152850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11154dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            my $ProblemType = "Removed_Virtual_Method";
11155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"}) {
11156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $ProblemType = "Removed_Pure_Virtual_Method";
11157dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11159dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$RemovedVFunc}}}=(
11160dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11161dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($RemovedVFunc, 1)  );
1116262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
111631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
111691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
111701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Source-level
111711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
111721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
111731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
111741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
111751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
111761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
111771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
111781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
111791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
111811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
111831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
11184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
111851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Pure_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
111861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
111871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
11188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byName($$)
11194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Name, $Pair_Type) = @_;
11196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Member_Name=~s/\A[_]+|[_]+\Z//g;
11197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos})
11200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Name = $Pair_Type->{"Memb"}{$MemberPair_Pos}{"name"};
11202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Name=~s/\A[_]+|[_]+\Z//g;
11203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name eq $Member_Name) {
11204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MemberPair_Pos;
11205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byVal($$)
11212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Value, $Pair_Type) = @_;
11214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos}
11217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Pair_Type->{"Memb"}{$MemberPair_Pos}{"value"} eq $Member_Value) {
11218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $MemberPair_Pos;
11219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
112248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub isRecurType($$$)
11225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
112268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach (@{$_[2]})
11227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1122862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if( $_->{"T1"} eq $_[0]
1122962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $_->{"T2"} eq $_[1] )
11230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
112378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub pushType($$$)
11238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
112398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my %IDs = (
112408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T1" => $_[0],
112418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T2" => $_[1]
112421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
112438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    push(@{$_[2]}, \%IDs);
11244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRenamed($$$$$)
11247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MemPos, $Type1, $LVersion1, $Type2, $LVersion2) = @_;
11249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Member_Name = $Type1->{"Memb"}{$MemPos}{"name"};
11250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemberType_Id = $Type1->{"Memb"}{$MemPos}{"type"};
11251f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %MemberType_Pure = get_PureType($MemberType_Id, $TypeInfo{$LVersion1});
11252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not defined $Type2->{"Memb"}{$MemPos}) {
11253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
11254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1125562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $PairType_Id = $Type2->{"Memb"}{$MemPos}{"type"};
11256f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{$LVersion2});
11257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1125862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Pair_Name = $Type2->{"Memb"}{$MemPos}{"name"};
1125962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MemberPair_Pos_Rev = ($Member_Name eq $Pair_Name)?$MemPos:find_MemberPair_Pos_byName($Pair_Name, $Type1);
11260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemberPair_Pos_Rev eq "lost")
11261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1126262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Name"} eq $PairType_Pure{"Name"})
1126362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # base type match
1126462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1126662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LVersion1}{$MemberType_Id}{"Name"} eq $TypeInfo{$LVersion2}{$PairType_Id}{"Name"})
1126762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # exact type match
1126862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1127062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Size"} eq $PairType_Pure{"Size"})
1127162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # size match
1127262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1127462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(isReserved($Pair_Name))
1127562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # reserved fields
1127662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
11280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLastElem($$)
11283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $TypeRef) = @_;
11285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $TypeRef->{"Memb"}{$Pos}{"name"};
11286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/last|count|max|total/i)
11287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GST_LEVEL_COUNT, GST_RTSP_ELAST
11288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/END|NLIMITS\Z/)
11291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # __RLIMIT_NLIMITS
11292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/\AN[A-Z](.+)[a-z]+s\Z/
11295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Pos+1==keys(%{$TypeRef->{"Memb"}}))
11296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # NImageFormats, NColorRoles
11297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub nonComparable($$)
11303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($T1, $T2) = @_;
11305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N1 = $T1->{"Name"};
11307fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N2 = $T2->{"Name"};
11308fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11309fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N1=~s/\A(struct|union|enum) //;
11310fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N2=~s/\A(struct|union|enum) //;
11311fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11312fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($N1 ne $N2
11313fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N1)
11314fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N2))
11315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different names
11316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} ne "Pointer"
11317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $T2->{"Type"} ne "Pointer")
11318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # compare base types
11319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11321fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($N1!~/\Avoid\s*\*/
11322fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $N2=~/\Avoid\s*\*/)
11323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($T1->{"Type"} ne $T2->{"Type"})
11328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
11329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} eq "Class"
11330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T2->{"Type"} eq "Struct")
11331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "struct"
11332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($T2->{"Type"} eq "Class"
11335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T1->{"Type"} eq "Struct")
11336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "struct" to "class"
11337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "enum"
11341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # "union" to "class"
11342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
11343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11349fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub isOpaque($)
11350fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
11351fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T = $_[0];
11352fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not defined $T->{"Memb"})
11353fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11354fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
11355fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11356fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
11357fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11358fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11359fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removeVPtr($)
11360fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{ # support for old ABI dumps
11361fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $TPtr = $_[0];
11362fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my @Pos = sort {int($a)<=>int($b)} keys(%{$TPtr->{"Memb"}});
11363fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Pos>=1)
11364fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11365fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Pos (0 .. $#Pos-1)
11366fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11367fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$TPtr->{"Memb"}{$Pos}} = %{$TPtr->{"Memb"}{$Pos+1}};
11368fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($TPtr->{"Memb"}{$#Pos});
11370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11371fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1137362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub mergeTypes($$$)
11374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1137562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
11376f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Id or not $Type2_Id);
11377f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1137862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id})
11379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already merged
11380f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id};
11381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11382f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1138362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1138462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
113851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Type1{"Name"} or not $Type2{"Name"}) {
11386f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
113871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
11388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1{"Name"}} = 1;
11390f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
11391f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
11392f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1_Pure{"Name"}} = 1;
11394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11395f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my %SubProblems = ();
11396f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
11398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Type1_Pure{"Type"}=~/Struct|Union/
11400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $Type2_Pure{"Type"}=~/Struct|Union/)
11401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(isOpaque(\%Type2_Pure) and not isOpaque(\%Type1_Pure))
11403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$SubProblems{"Type_Became_Opaque"}{$Type1_Pure{"Name"}}}=(
11405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
11406fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11407fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11408f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11409fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11410fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11411fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11412fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11413177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Type1_Pure{"Size"}
11414177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    or not $Type2_Pure{"Size"})
11415850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # including a case when "class Class { ... };" changed to "class Class;"
11416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $Type1_Pure{"Memb"} or not defined $Type2_Pure{"Memb"}
11417177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or index($Type1_Pure{"Name"}, "<")==-1 or index($Type2_Pure{"Name"}, "<")==-1)
11418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # NOTE: template instances have no size
11419f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return {};
11420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
11421850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
114228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes))
11423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip recursive declarations
11424f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
11425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11426f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Pure{"Name"} or not $Type2_Pure{"Name"});
11427f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1_Pure{"Name"}});
11428f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1{"Name"}});
11429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1143028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if(defined $TargetHeadersPath)
1143128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    {
1143228874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(not isTargetType($Type1_Pure{"Tid"}, 1)) {
1143328874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return {};
1143428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1143528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1143628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
11437fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Type"}=~/Class|Struct/ and $Type2_Pure{"Type"}=~/Class|Struct/)
11438fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
11439fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      # _vptr field added in 3.0
11440fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not checkDump(1, "3.0") and checkDump(2, "3.0"))
11441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type2_Pure{"Memb"}
11443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type2_Pure{"Memb"}{0}{"name"} eq "_vptr")
11444fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type2_Pure{"Memb"}})==1) {
11446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type2_Pure{"Memb"}{0});
11447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type2_Pure);
11450fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11451fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(checkDump(1, "3.0") and not checkDump(2, "3.0"))
11454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type1_Pure{"Memb"}
11456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type1_Pure{"Memb"}{0}{"name"} eq "_vptr")
11457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type1_Pure{"Memb"}})==1) {
11459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type1_Pure{"Memb"}{0});
11460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type1_Pure);
11463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1146862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
1146962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
11470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
114716ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    if(%Typedef_1 and %Typedef_2
11472dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef"
11473dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Name"} eq $Typedef_2{"Name"})
11474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11475f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_1 = get_OneStep_BaseType($Typedef_1{"Tid"}, $TypeInfo{1});
11476f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_2 = get_OneStep_BaseType($Typedef_2{"Tid"}, $TypeInfo{2});
11477850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base_1{"Name"} ne $Base_2{"Name"})
11478850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
11479850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(differentDumps("G")
11480850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or differentDumps("V"))
11481850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # different GCC versions or different dumps
11482850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"} = uncover_typedefs($Base_1{"Name"}, 1);
11483850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"} = uncover_typedefs($Base_2{"Name"}, 2);
11484850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # std::__va_list and __va_list
11485850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"}=~s/\A(\w+::)+//;
11486850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"}=~s/\A(\w+::)+//;
114879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_1{"Name"} = formatName($Base_1{"Name"}, "T");
114889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_2{"Name"} = formatName($Base_2{"Name"}, "T");
11489850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
11490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Base_1{"Name"}!~/anon\-/ and $Base_2{"Name"}!~/anon\-/
11492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Base_1{"Name"} ne $Base_2{"Name"})
11493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
114941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
11495d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            and $Type1{"Size"} and $Type2{"Size"}
114961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Type1{"Size"} ne $Type2{"Size"})
11497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"DataType_Size"}{$Typedef_1{"Name"}}}=(
11499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Typedef_1{"Name"},
11500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Typedef_1{"Name"},
11501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
11502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE  );
11503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
115048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base1_Pure = get_PureType($Base_1{"Tid"}, $TypeInfo{1});
115058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base2_Pure = get_PureType($Base_2{"Tid"}, $TypeInfo{2});
11506fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(tNameLock($Base_1{"Tid"}, $Base_2{"Tid"}))
115078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
11508fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(diffTypes($Base1_Pure{"Tid"}, $Base2_Pure{"Tid"}, $Level))
11509fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11510fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType_Format"}{$Typedef_1{"Name"}}}=(
11511fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11512fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11513fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11514fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11515fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11516fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
11517fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11518fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType"}{$Typedef_1{"Name"}}}=(
11519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11520fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11521fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11522fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11523fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
115248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
11525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(nonComparable(\%Type1_Pure, \%Type2_Pure))
11528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types (reported in detectTypeChange(...))
1152974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT1 = $Type1_Pure{"Type"};
1153074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT2 = $Type2_Pure{"Type"};
1153174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1153274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($TT1 ne $TT2
1153374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        and $TT1!~/Intrinsic|Pointer|Ref|Typedef/)
11534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different type of the type
1153574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short1 = $Type1_Pure{"Name"};
1153674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short2 = $Type2_Pure{"Name"};
1153774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1153874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short1=~s/\A\Q$TT1\E //ig;
1153974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short2=~s/\A\Q$TT2\E //ig;
1154074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1154174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($Short1 eq $Short2)
1154274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1154374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                %{$SubProblems{"DataType_Type"}{$Type1_Pure{"Name"}}}=(
1154474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
1154574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
1154674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Old_Value"=>lc($Type1_Pure{"Type"}),
1154774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>lc($Type2_Pure{"Type"})  );
1154874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
11549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11550f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
115528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes);
11553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}
11554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or (isAnon($Type1_Pure{"Name"}) and isAnon($Type2_Pure{"Name"})))
11555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking size
115571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
11558d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        and $Type1_Pure{"Size"} and $Type2_Pure{"Size"}
115591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ProblemKind = "DataType_Size";
11562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Class"
115631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$ClassMethods{$Level}{1}{$Type1_Pure{"Name"}}}))
11564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isCopyingClass($Type1_Pure{"Tid"}, 1)) {
11566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemKind = "Size_Of_Copying_Class";
11567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($AllocableClass{1}{$Type1_Pure{"Name"}})
11569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(int($Type2_Pure{"Size"})>int($Type1_Pure{"Size"})) {
11571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemKind = "Size_Of_Allocable_Class_Increased";
11572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11573fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    else
11574fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
11575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # descreased size of allocable class
11576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # it has no special effects
11577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$SubProblems{$ProblemKind}{$Type1_Pure{"Name"}}}=(
11581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Type1_Pure{"Name"},
11582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Type_Name"=>$Type1_Pure{"Name"},
11583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Size"=>$Type1_Pure{"Size"}*$BYTE_SIZE,
11584f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "New_Size"=>$Type2_Pure{"Size"}*$BYTE_SIZE);
11585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Type1_Pure{"BaseType"}
11588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and defined $Type2_Pure{"BaseType"})
115890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # checking base types
11590f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Sub_SubProblems = mergeTypes($Type1_Pure{"BaseType"}, $Type2_Pure{"BaseType"}, $Level);
11591f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
11592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11593f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}})) {
11594f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
11595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%AddedField, %RemovedField, %RenamedField, %RenamedField_Rev, %RelatedField, %RelatedField_Rev) = ();
11599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosA = map {$Type1_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type1_Pure{"Memb"}});
11600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosB = map {$Type2_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type2_Pure{"Memb"}});
11601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect removed and renamed fields
11603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isUnnamed($Member_Name))
11611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # support for old-version dumps
11612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1161362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(not checkDump(2, "2.1")) {
11614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $RenamedTo = isRenamed($Member_Pos, \%Type1_Pure, 1, \%Type2_Pure, 2))
11618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11619082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField{$Member_Pos} = $RenamedTo;
11620082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11624082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MemberPair_Pos = find_MemberPair_Pos_byVal($Member_Value1, \%Type2_Pure);
11632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberPair_Pos ne "lost")
11633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $RenamedTo = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"name"};
11635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $MemberPair_Pos_Rev = find_MemberPair_Pos_byName($RenamedTo, \%Type1_Pure);
11636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberPair_Pos_Rev eq "lost")
11637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
11638082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField{$Member_Pos} = $RenamedTo;
11639082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else {
11642082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RemovedField{$Member_Pos} = 1;
11643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11647082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # related
11653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField{$Member_Pos} = $MemberPair_Pos;
11654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField_Rev{$MemberPair_Pos} = $Member_Pos;
11655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added fields
11659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isUnnamed($Member_Name))
11665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old-version dumps
116661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1166762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not checkDump(1, "2.1")) {
11668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union|Enum)\Z/)
11672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $RenamedField_Rev{$Member_Pos})
11674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added
11675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $AddedField{$Member_Pos}=1;
11676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect moved fields
11682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (%RelPos, %RelPosName, %AbsPos) = ();
11683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
11684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 1st version
11686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $RemovedField{$Member_Pos})
11689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # old type without removed fields
11690082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{1}{$Member_Name} = $Pos;
11691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{1}{$Pos} = $Member_Name;
11692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{1}{$Pos++} = $Member_Pos;
11693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Pos = 0;
11696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 2nd version
11698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $AddedField{$Member_Pos})
11701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # new type without added fields
11702082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{2}{$Member_Name} = $Pos;
11703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{2}{$Pos} = $Member_Name;
11704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{2}{$Pos++} = $Member_Pos;
11705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Name (keys(%{$RelPos{1}}))
11708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos1 = $RelPos{1}{$Member_Name};
11710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $AbsPos1 = $NameToPosA{$Member_Name};
11711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name2 = $Member_Name;
11712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $RenamedTo = $RenamedField{$AbsPos1})
11713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # renamed
11714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Member_Name2 = $RenamedTo;
11715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos2 = $RelPos{2}{$Member_Name2};
11717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RPos2 ne "" and $RPos1 ne $RPos2)
11718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different relative positions
11719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $AbsPos2 = $NameToPosB{$Member_Name2};
11720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($AbsPos1 ne $AbsPos2)
11721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # different absolute positions
11722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Moved_Field";
11723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not isPublic(\%Type1_Pure, $AbsPos1))
11724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # may change layout and size of type
117251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Source") {
117261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
117271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Moved_Private_Field";
11729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
117301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Binary"
117311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
1173362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize1 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$AbsPos1}{"type"}}{"Size"};
11734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $MovedAbsPos = $AbsPos{1}{$RPos2};
1173562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize2 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$MovedAbsPos}{"type"}}{"Size"};
11736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($MemSize1 ne $MemSize2) {
11737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Size";
11738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Moved_Private_Field") {
11741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$RPos1,
11747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RPos2 );
11748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
117531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check older fields, public and private
11754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11756082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
11757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RenamedTo = $RenamedField{$Member_Pos})
11758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # renamed
117598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Constants{2}{$Member_Name})
117608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
117618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Constants{2}{$Member_Name}{"Value"} eq $RenamedTo)
117628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # define OLD NEW
117638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next; # Safe
117648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
117658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
117668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
11767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isPublic(\%Type1_Pure, $Member_Pos))
11770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Renamed_Field"}{$Member_Name}}=(
11772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
11775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
11776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
117779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(isReserved($Member_Name))
117789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
117799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    %{$SubProblems{"Used_Reserved_Field"}{$Member_Name}}=(
117809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Target"=>$Member_Name,
117819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
117829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
117839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
117849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
11785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Name"}{$Type1_Pure{"Memb"}{$Member_Pos}{"value"}}}=(
11789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Memb"}{$Member_Pos}{"value"},
11790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name,
11792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$RenamedTo  );
11793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RemovedField{$Member_Pos})
11796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # removed
11797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Removed_Field";
11800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos)
118011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
118021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
118031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
118041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
118051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
11806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Removed_Private_Field";
11807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
118081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected fields
11813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
11815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
11816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
11820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
11821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Removed_Private_Field") {
11824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
11827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1182874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
11831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
118321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
118331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field_And_Size"}{$Member_Name}}=(
11836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1183774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field"}{$Member_Name}}=(
11842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1184374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Removed"}{$Member_Name}}=(
11849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
11850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name  );
11852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # changed
11856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $MemberPair_Pos = $RelatedField{$Member_Pos};
11857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Enum")
11858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"value"};
11862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value2 eq "");
11863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Member_Value1 ne $Member_Value2)
11864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Enum_Member_Value";
11866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isLastElem($Member_Pos, \%Type1_Pure)) {
11867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Enum_Last_Member_Value";
11868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11869fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($SkipConstants{1}{$Member_Name}) {
11870fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemType = "Enum_Private_Member_Value";
11871fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
11872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Value1,
11876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Member_Value2  );
11877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11881fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access1 = $Type1_Pure{"Memb"}{$Member_Pos}{"access"};
11882fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"access"};
11883fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11884fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Access1 ne "private"
11885fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "private")
11886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11887fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Private"}{$Member_Name}}=(
11888fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
11889fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
11890fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11891fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Access1 ne "protected"
11892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access1 ne "private"
11893fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "protected")
11894fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11895fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Protected"}{$Member_Name}}=(
11896fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
11897fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
11898fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType1_Id = $Type1_Pure{"Memb"}{$Member_Pos}{"type"};
11901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType2_Id = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"type"};
1190262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV1 = $TypeInfo{1}{$MemberType1_Id}{"Size"}*$BYTE_SIZE;
11903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize1 = $Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}) {
11904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV1 = $BSize1;
11905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1190662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV2 = $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE;
11907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}) {
11908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV2 = $BSize2;
11909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1191062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType1_Name = $TypeInfo{1}{$MemberType1_Id}{"Name"};
1191162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType2_Name = $TypeInfo{2}{$MemberType2_Id}{"Name"};
119121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11913d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                and $SizeV1 and $SizeV2
119141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $SizeV1 ne $SizeV2)
11915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberType1_Name eq $MemberType2_Name or (isAnon($MemberType1_Name) and isAnon($MemberType2_Name))
11917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"} and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}))
11918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # field size change (including anon-structures and unions)
11919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - same types
11920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - unnamed types
11921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - bitfields
11922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Field_Size";
11923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
11924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name))
11925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # should not be accessed by applications, goes to "Low Severity"
11926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                          # example: "abidata" members in GStreamer types
11927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
11928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11929fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
11931fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
11932fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
11934fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
11936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
11937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
11940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
11941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType eq "Private_Field_Size")
11944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # private field size with no effect
11945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1194646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($ProblemType eq "Field_Size")
1194746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        {
1194846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            if($Type1_Pure{"Type"}=~/Union|Struct/ and $SizeV1<$SizeV2)
1194946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            { # Low severity
1195046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                                $ProblemType = "Struct_Field_Size_Increased";
1195146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            }
1195246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
11953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType)
11954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # register a problem
11955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            %{$SubProblems{$ProblemType}{$Member_Name}}=(
11956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Target"=>$Member_Name,
11957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Type_Name"=>$Type1_Pure{"Name"},
11958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Old_Size"=>$SizeV1,
11959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "New_Size"=>$SizeV2);
11960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}
11964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"})
11965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check bitfield type changes
11966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1196862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(checkDump(1, "2.13") and checkDump(2, "2.13"))
119690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
119700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not $Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
119710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
119720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
119730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Mutable"}{$Member_Name}}=(
119740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1197574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
119760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
119770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    elsif($Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
119780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and not $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
119790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
11980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Non_Mutable"}{$Member_Name}}=(
119810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1198274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
119830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
119840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
11985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my %Sub_SubChanges = detectTypeChange($MemberType1_Id, $MemberType2_Id, "Field", $Level);
11986f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
11987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11988f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
11989f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
11990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11991fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    # quals
11992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type"
11993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_And_Size"
11994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_Format")
11995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1199662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(checkDump(1, "2.6") and checkDump(2, "2.6"))
11997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
11998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(addedQual($Old_Value, $New_Value, "volatile")) {
11999f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
120000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            elsif(removedQual($Old_Value, $New_Value, "volatile")) {
12002f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
12003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
120050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(my $RA = addedQual($Old_Value, $New_Value, "const"))
120060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
120070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RA==2) {
12008f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Added_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12011f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
120140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
120150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
120160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RR==2) {
12017f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Removed_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12020f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Const"}} = %{$Sub_SubChanges{$ProblemType}};
120210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12022fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
12023fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12024fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12025fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12026fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Source")
12027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12028f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $ProblemType (keys(%Sub_SubChanges))
12029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
12030f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12031f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12032fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($ProblemType eq "Field_Type")
12034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
12035fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
12036f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                delete($Sub_SubChanges{$ProblemType});
120370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
120380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
12039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12042f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType_Init = $ProblemType;
12045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type_And_Size")
120461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # Binary
12047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
12067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12068d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        # TODO: Private_Field_Type rule?
12069d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
12070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
12073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Private_Field_Type_And_Size")
12076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # private field change with no effect
12077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1208074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
1208174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
12082f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Attr (keys(%{$Sub_SubChanges{$ProblemType_Init}}))
12083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # other properties
12084f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $SubProblems{$ProblemType}{$Member_Name}{$Attr} = $Sub_SubChanges{$ProblemType_Init}{$Attr};
12085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos))
12088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check internal type changes
12089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberType1_Id and $MemberType2_Id)
12092f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # checking member type changes
12093f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Sub_SubProblems = mergeTypes($MemberType1_Id, $MemberType2_Id, $Level);
12094f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12095f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my %DupProblems = ();
12096f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12097f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
12098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12099f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}}))
12100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12101f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12102f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12103f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                if(defined $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}}) {
12104f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    next;
12105f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                }
12106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12107f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12108f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $NewLocation = ($Sub_SubLocation)?$Member_Name."->".$Sub_SubLocation:$Member_Name;
12109f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            $SubProblems{$Sub_SubProblemType}{$NewLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
12110f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12111f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12112f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12113f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}} = 1;
12114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12117f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12118f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %DupProblems = ();
12119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
12124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added members, public and private
12125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
12126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
12127082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
12128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AddedField{$Member_Pos})
12129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # added
12130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
12131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Added_Field";
12133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type2_Pure, $Member_Pos)
121341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
121351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
121361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
121371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
121381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Added_Private_Field";
12140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
121411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12142fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type2_Pure, \%AddedField, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type2_Pure, \%AddedField, $Member_Pos, -1))
12145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # public fields after the current
12146fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
12148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
12149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
12153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Added_Private_Field")
12156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # skip added private fields
12157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
12160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1216174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"});
12162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
12164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
121651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
121661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
12167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field_And_Size"}{$Member_Name}}=(
12169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1217074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field"}{$Member_Name}}=(
12175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1217674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Enum")
12180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value = $Type2_Pure{"Memb"}{$Member_Pos}{"value"};
12182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value eq "");
12183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Added_Enum_Member"}{$Member_Name}}=(
12184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type2_Pure{"Name"},
1218674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>$Member_Value);
12187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12190f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurTypes);
12192f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
12193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isUnnamed($) {
12196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0]=~/\Aunnamed\d+\Z/;
12197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1219974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_ShortClass($$)
12200dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{
12201dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1220274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TypeName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
1220374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeInfo{$LibVersion}{$TypeId}{"Type"}!~/Intrinsic|Class|Struct|Union|Enum/) {
1220474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName = uncover_typedefs($TypeName, $LibVersion);
1220574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1220662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $NameSpace = $TypeInfo{$LibVersion}{$TypeId}{"NameSpace"}) {
1220774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName=~s/\A(struct |)\Q$NameSpace\E\:\://g;
12208dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
12209dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $TypeName;
12210dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
12211dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1221262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub goToFirst($$$)
12213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1221462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion, $Type_Type) = @_;
122151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return () if(not $TypeId);
1221662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}) {
1221762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}};
12218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1221962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1222062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type{"Type"});
12222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} ne $Type_Type)
12223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return () if(not $Type{"BaseType"});
12225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = goToFirst($Type{"BaseType"}, $LibVersion, $Type_Type);
12226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1222762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type} = \%Type;
12228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TypeSpecAttributes = (
12232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Const" => 1,
12233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Volatile" => 1,
12234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ConstVolatile" => 1,
12235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Restrict" => 1,
12236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Typedef" => 1
12237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
12238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1223962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PureType($$)
12240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12241f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12242f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12243f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12244f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12246f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(defined $Cache{"get_PureType"}{$TypeId}{$Info}) {
12247f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %{$Cache{"get_PureType"}{$TypeId}{$Info}};
12248f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12249f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeSpecAttributes{$Type{"Type"}}) {
12252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = get_PureType($Type{"BaseType"}, $Info);
12253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12254f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $Cache{"get_PureType"}{$TypeId}{$Info} = \%Type;
12255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1225862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PLevel($$)
12259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1226062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypeId);
1226262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_PLevel"}{$TypeId}{$LibVersion}) {
1226362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_PLevel"}{$TypeId}{$LibVersion};
12264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1226562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $TypeInfo{$LibVersion}{$TypeId});
1226662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12267fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 1 if($Type{"Type"}=~/FuncPtr|FieldPtr/);
12268fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $PLevel = 0;
12269fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type{"Type"} =~/Pointer|Ref|FuncPtr|FieldPtr/) {
12270fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $PLevel += 1;
12271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel if(not $Type{"BaseType"});
12273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $PLevel += get_PLevel($Type{"BaseType"}, $LibVersion);
12274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $Cache{"get_PLevel"}{$TypeId}{$LibVersion} = $PLevel;
12275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel;
12276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1227862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseType($$)
12279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1228062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $TypeId);
1228262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_BaseType"}{$TypeId}{$LibVersion}) {
1228362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"get_BaseType"}{$TypeId}{$LibVersion}};
12284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1228562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1228662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12287fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12288fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    %Type = get_BaseType($Type{"BaseType"}, $LibVersion);
1228962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"get_BaseType"}{$TypeId}{$LibVersion} = \%Type;
12290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1229362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseTypeQual($$)
12294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1229562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeId);
1229762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $TypeInfo{$LibVersion}{$TypeId});
1229862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12299fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return "" if(not $Type{"BaseType"});
12300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Qual = "";
12301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} eq "Pointer") {
12302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "*";
12303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Ref") {
12305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "&";
12306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "ConstVolatile") {
12308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "const volatile";
12309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Const"
12311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Volatile"
12312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Restrict") {
12313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= lc($Type{"Type"});
12314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $BQual = get_BaseTypeQual($Type{"BaseType"}, $LibVersion);
12316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $BQual.$Qual;
12317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1231962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_OneStep_BaseType($$)
12320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12321f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12322f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12323f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12324f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12325f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12326f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12327fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12328fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(my $BTid = $Type{"BaseType"})
12329f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
12330f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Info->{$BTid}) {
12331f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return %{$Info->{$BTid}};
12332f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12333f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else { # something is going wrong
12334f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return ();
12335f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12336f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12337f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    else {
12338f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %Type;
12339f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1234262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_Type($$)
12343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1234462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12345dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return () if(not $TypeId);
1234662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1234762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return %{$TypeInfo{$LibVersion}{$TypeId}};
12348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12350989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub isPrivateData($)
123510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{ # non-public global data
12352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
12353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Symbol=~/\A(_ZGV|_ZTI|_ZTS|_ZTT|_ZTV|_ZTC|_ZThn|_ZTv0_n)/);
12354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12356ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isInLineInst($$) {
1235701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return (isTemplateInstance(@_) and not isTemplateSpec(@_));
1235801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1235901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
12360ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateInstance($$)
12361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12362ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
12363ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12364ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
1236562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12366ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"})
1236762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
12368ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(index($ClassName,"<")!=-1) {
12369ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 1;
1237062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1237162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1237262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12373ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my $ShortName = $SInfo->{"ShortName"})
1237462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
12375ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(index($ShortName,"<")!=-1
12376ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        and index($ShortName,">")!=-1) {
12377ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            return 1;
1237862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1237962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
12380ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1238162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
12382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12384ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenkosub isTemplateSpec($$)
12385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12386ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my ($SInfo, $LibVersion) = @_;
1238701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
12388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1238962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$ClassId}{"Spec"})
12390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class specialization
12391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1239301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        elsif($SInfo->{"Spec"})
12394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # method specialization
12395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
12399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
124011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub symbolFilter($$$$)
12402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # some special cases when the symbol cannot be imported
124031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $LibVersion, $Type, $Level) = @_;
12404ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12405989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isPrivateData($Symbol))
12406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # non-public global data
12407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
12408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12409d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
12410d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if(defined $SkipInternal)
12411d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
12412d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        return 0 if($Symbol=~/($SkipInternal)/);
12413d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
12414d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1241528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    if($Symbol=~/\A_Z/)
1241628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    {
1241728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Symbol=~/[CD][3-4]E/) {
1241828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            return 0;
1241928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1242028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko    }
1242128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1242262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckHeadersOnly and not checkDump($LibVersion, "2.7"))
12423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps in --headers-only mode
12424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Pos (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
12425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Pid = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"})
12427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1242862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType = $TypeInfo{$LibVersion}{$Pid}{"Type"};
12429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $PType or $PType eq "Unknown") {
12430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12435850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type=~/Affected/)
12436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12437ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my $Header = $CompleteSignature{$LibVersion}{$Symbol}{"Header"};
12438ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipSymbols{$LibVersion}{$Symbol})
12440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols to ignore
12441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12443ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12444ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($SymbolsListPath and not $SymbolsList{$Symbol})
12445ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols
12446ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(not $TargetHeadersPath or not $Header
12447ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or not is_target_header($Header, 1))
12448ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # -symbols-list | -headers-list
12449ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                return 0;
12450ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
12451ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12452ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
12453ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($AppPath and not $SymbolsList_App{$Symbol})
12454ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # user defined symbols (in application)
12455ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            return 0;
12456ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
12457ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12458ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"};
12459ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
12461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $NameSpace and $ClassId)
12462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class methods have no "NameSpace" attribute
1246362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $NameSpace = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"};
12464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($NameSpace)
12466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined namespaces to ignore
12467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SkipNameSpaces{$LibVersion}{$NameSpace}) {
12468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
12469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NS (keys(%{$SkipNameSpaces{$LibVersion}}))
12471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nested namespaces
12472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NameSpace=~/\A\Q$NS\E(\:\:|\Z)/) {
12473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12477ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($Header)
12478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1247962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Skip = skipHeader($Header, $LibVersion))
12480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # --skip-headers or <skip_headers> (not <skip_including>)
12481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip==1) {
12482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12486ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if($TypesListPath and $ClassId)
1248752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        { # user defined types
1248852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1248952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1249052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if(not $TypesList{$CName})
1249152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
12492ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(my $NS = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"})
12493ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12494ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    $CName=~s/\A\Q$NS\E\:\://g;
12495ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
12496ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12497ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                if(not $TypesList{$CName})
12498ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                {
12499ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    my $Found = 0;
12500ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12501ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    while($CName=~s/\:\:.+?\Z//)
12502ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    {
12503ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        if($TypesList{$CName})
12504ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        {
12505ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            $Found = 1;
12506ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                            last;
12507ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        }
12508ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12509ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12510ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    if(not $Found) {
12511ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                        return 0;
12512ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                    }
12513ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                }
1251452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1251552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
12516ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
12517850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $Level, $LibVersion))
12518850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
12519850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 0;
12520850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
125211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
12522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12523ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
12524ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            or isInLineInst($CompleteSignature{$LibVersion}{$Symbol}, $LibVersion))
125251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
12526ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                if($ClassId and $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
12527ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline virtual methods
12528ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if($Type=~/InlineVirt/) {
12529ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        return 1;
12530ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    }
12531ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    my $Allocable = (not isCopyingClass($ClassId, $LibVersion));
12532ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable)
12533ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    { # check bases
12534ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        foreach my $DCId (get_sub_classes($ClassId, $LibVersion, 1))
12535ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                        {
12536ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            if(not isCopyingClass($DCId, $LibVersion))
12537ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                            { # exists a derived class without default c-tor
12538ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                $Allocable=1;
12539ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                                last;
125401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
12541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12543ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    if(not $Allocable) {
125441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        return 0;
125451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12547ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                else
12548ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                { # inline non-virtual methods
12549ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                    return 0;
12550ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                }
12551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
12555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded($)
12558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
125591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{2}}))
12561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 1, "+Deps"))
12563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find a new symbol
12564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the old-version library
12565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # So, it's not a new symbol
12566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{2}{$Symbol}
1256962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
125721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $AddedInt{$Level}{$Symbol} = 1;
12573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved($)
12577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
125781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{1}}))
12580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 2, "+Deps"))
12582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find an old symbol
12583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the new-version library
12584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{1}{$Symbol}
1258762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
125901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RemovedInt{$Level}{$Symbol} = 1;
12591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeLibs($)
12595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
125961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
125971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
12600ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{2}{$Symbol}{"Header"});
12601c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected + InlineVirt", $Level));
126021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
126041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
12607ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Symbol}{"Header"});
126089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_ZTV")==0)
12609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip v-tables for templates, that should not be imported by applications
12610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($tr_name{$Symbol}=~/</);
12611dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $CName = $VTableClass{$Symbol})
12612dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12613dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(not keys(%{$ClassMethods{$Level}{1}{$CName}}))
12614dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # vtables for "private" classes
126150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # use case: vtable for QDragManager (Qt 4.5.3 to 4.6.0) became HIDDEN symbol
12616dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    next;
12617dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
12618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12621c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko            next if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level));
12622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"})
12624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # symbols for pure virtual methods cannot be called by clients
12625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
126271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1263162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub checkDump($$)
126321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
1263362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($LibVersion, $V) = @_;
1263462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"checkDump"}{$LibVersion}{$V}) {
1263562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"checkDump"}{$LibVersion}{$V};
1263662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1263762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"checkDump"}{$LibVersion}{$V} = (not $UsedDump{$LibVersion}{"V"} or cmpVersions($UsedDump{$LibVersion}{"V"}, $V)>=0));
126381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
126391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
126401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded_H($)
12641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
126421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{2}}))
12644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
126451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
126461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
126471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
126481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
12649b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
12650b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"Artificial"})
12651b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            { # skip artificial constructors
12652b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                next;
12653b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
126541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
126551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}
126561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"}) {
126571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
126581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1265962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
126621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
126631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"})
126641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
126651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{2}{"SrcBin"})
126661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
1266762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{1}{"BinOnly"} or not checkDump(1, "2.11"))
126681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # support for old and different (!) ABI dumps
126691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{2}{$Symbol}{"Virt"}
126701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{2}{$Symbol}{"PureVirt"})
126711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
126721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
12673850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        {
12674850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{2}{$Symbol}{"Lang"})
12675850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12676850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12677850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12678850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12679850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12680850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
126811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
126821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
126831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
126841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 2, "-Deps"))
126850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            { # skip added inline symbols and const global data
126861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
126871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
126881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
126891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
126901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
126911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
126921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedInt{$Level}{$Symbol} = 1;
12693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
126971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved_H($)
12698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
126991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
12701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
127021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
127031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
127041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
127051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
127061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
127071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
127081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"}) {
127091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
127101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1271162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
127141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{2}{$Symbol}
127151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"})
12716850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
127171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{1}{"SrcBin"})
127181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1271962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{2}{"BinOnly"} or not checkDump(2, "2.11"))
12720850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # support for old and different (!) ABI dumps
127211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{1}{$Symbol}{"Virt"}
127221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{1}{$Symbol}{"PureVirt"})
127231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
127241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
127251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # skip all removed symbols
12726850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{1}{$Symbol}{"Lang"})
12727850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12728850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12730850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12731850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12732850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
127331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
127341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
127351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
127361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 1, "-Deps"))
127371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            { # skip removed inline symbols
127381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
127391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
127401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
127411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
127421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
127431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12744b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not checkDump(1, "2.15"))
12745b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            {
12746b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                if($Symbol=~/_IT_E\Z/)
12747b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                { # _ZN28QExplicitlySharedDataPointerI22QSslCertificatePrivateEC1IT_EERKS_IT_E
12748b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                    next;
12749b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                }
12750b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
127519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Class"})
127529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
127539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Short = $CompleteSignature{1}{$Symbol}{"ShortName"})
127549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
127559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(defined $Constants{2}{$Short})
127569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
127579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        my $Val = $Constants{2}{$Short}{"Value"};
127589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(defined $Func_ShortName{2}{$Val})
127599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # old name defined to new
127609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
127619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
127629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
127639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
127649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
127659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
127661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RemovedInt{$Level}{$Symbol} = 1;
127671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
127681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # search for a source-compatible equivalent
127691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                setAlternative($Symbol, $Level);
127701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeHeaders($)
12776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
127771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
127781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"PureVirt"});
127819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
127829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected", $Level));
12783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"InLine"})
12786850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12787850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{2}{$Symbol}{"Virt"})
12788850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12789850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12790850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12791850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
127921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
127931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
127941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
127951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($SourceAlternative_B{$Symbol}) {
127961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
127971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
127981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
127991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
128011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"PureVirt"});
128049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
128059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 1, "Affected", $Level));
12806850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
12807850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
12808850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"InLine"})
12809850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
12810850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{1}{$Symbol}{"Virt"})
12811850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
12812850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
12813850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
12814850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
128151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
128171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
128180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Alt = $SourceAlternative{$Symbol})
128190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
128200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Alt}
128210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"Const"})
128220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
1282362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
12824f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Removed_Const_Overload"}{"this"}}=(
1282562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Type_Name"=>$TypeInfo{1}{$Cid}{"Name"},
1282674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Target"=>get_Signature($Alt, 1));
128270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
128280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                else
128290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # do NOT show removed symbol
128300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    next;
128310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
128321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
128331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
128341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addParamNames($)
12839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibraryVersion = $_[0];
12841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not keys(%AddIntParams));
12842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SecondVersion = $LibraryVersion==1?2:1;
12843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompleteSignature{$LibraryVersion}}))
12844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not keys(%{$AddIntParams{$Interface}}));
12846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibraryVersion}{$Interface}{"Param"}}))
12847850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # add absent parameter names
12848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamName = $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"};
12849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamName=~/\Ap\d+\Z/ and my $NewParamName = $AddIntParams{$Interface}{$ParamPos})
12850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # names from the external file
12851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(defined $CompleteSignature{$SecondVersion}{$Interface}
12852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and defined $CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos})
12853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos}{"name"}=~/\Ap\d+\Z/) {
12855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
12856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
12859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
12860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectChangedTypedefs()
12867989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # detect changed typedefs to show
12868989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  # correct function signatures
12869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Typedef (keys(%{$Typedef_BaseName{1}}))
12870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Typedef);
12872989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName1 = $Typedef_BaseName{1}{$Typedef};
12873989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName1 or isAnon($BName1)) {
12874989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
12875989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
12876989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName2 = $Typedef_BaseName{2}{$Typedef};
12877989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName2 or isAnon($BName2)) {
12878989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
12879989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
12880989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($BName1 ne $BName2) {
12881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedTypedef{$Typedef} = 1;
12882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_suffix($$)
12887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $Full) = @_;
128891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($SN, $SO, $SV) = separate_symbol($Symbol);
12890570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Symbol=$SN; # remove version
128911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Signature = $tr_name{$Symbol};
128921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Suffix = substr($Signature, find_center($Signature, "("));
12893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Full) {
12894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Suffix=~s/(\))\s*(const volatile|volatile const|const|volatile)\Z/$1/g;
12895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Suffix;
12897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_prefix($$)
12900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
12902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
12903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
12904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # methods
1290562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $ShortName = $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::".$ShortName;
12906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ShortName;
12908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub setAlternative($)
129111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
129121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Symbol = $_[0];
129131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $PSymbol = $Symbol;
129141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not defined $CompleteSignature{2}{$PSymbol}
129151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or (not $CompleteSignature{2}{$PSymbol}{"MnglName"}
129161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and not $CompleteSignature{2}{$PSymbol}{"ShortName"}))
129171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for a pair
12918dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $ShortName = $CompleteSignature{1}{$PSymbol}{"ShortName"})
129191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
12920dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($CompleteSignature{1}{$PSymbol}{"Data"})
129211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
12922dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($PSymbol=~s/L(\d+$ShortName(E)\Z)/$1/
12923dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or $PSymbol=~s/(\d+$ShortName(E)\Z)/L$1/)
129241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
129251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$PSymbol}
129261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $CompleteSignature{2}{$PSymbol}{"MnglName"})
129271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative{$Symbol} = $PSymbol;
129291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative_B{$PSymbol} = $Symbol;
129301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not defined $CompleteSignature{1}{$PSymbol}
129311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
129321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SourceReplacement{$Symbol} = $PSymbol;
129331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
12936dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
12937dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else
12938dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12939dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                foreach my $Sp ("KV", "VK", "K", "V")
12940dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
12941dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($PSymbol=~s/\A_ZN$Sp/_ZN/
12942dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    or $PSymbol=~s/\A_ZN/_ZN$Sp/)
12943dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
12944dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if(defined $CompleteSignature{2}{$PSymbol}
12945dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        and $CompleteSignature{2}{$PSymbol}{"MnglName"})
12946dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
12947dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative{$Symbol} = $PSymbol;
12948dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative_B{$PSymbol} = $Symbol;
12949dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if(not defined $CompleteSignature{1}{$PSymbol}
12950dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
12951dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $SourceReplacement{$Symbol} = $PSymbol;
12952dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
12953dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        }
12954dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
12955dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $PSymbol = $Symbol;
12956dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
129571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
129581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
129601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "";
129611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
129621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
129630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getSymKind($$)
129640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
129650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
129660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"})
129670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
129680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Global_Data";
129690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
129700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($CompleteSignature{$LibVersion}{$Symbol}{"Class"})
129710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
129720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Method";
129730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
129740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Function";
129750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
129760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
129778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub mergeSymbols($)
12978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SubProblems = ();
12981f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
129821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    mergeBases($Level);
129831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
12984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AddedOverloads = ();
129851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check all added exported symbols
129871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}) {
12988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
129900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{1}{$Symbol}
129910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Header"})
129920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check added symbol
129930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
129941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
12995850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 2, "Affected", $Level)) {
129961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
129971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
12999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
130001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedOverloads{get_symbol_prefix($Symbol, 2)}{get_symbol_suffix($Symbol, 1)} = $Symbol;
13001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
130021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{2}{$Symbol}{"Override"})
130031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1300462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{2}{$Symbol}{"Class"};
1300562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{2}{$Cid}{"Name"};
130060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $CompleteSignature{1}{$OverriddenMethod} and $CompleteSignature{1}{$OverriddenMethod}{"Virt"}
13007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $CompleteSignature{1}{$OverriddenMethod}{"Private"})
130080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{1}{$AffectedClass_Name})
130100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in previous version
130110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($TName_Tid{1}{$AffectedClass_Name}, 1))
130120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
130130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$OverriddenMethod}{"Overridden_Virtual_Method"}{$tr_name{$Symbol}}}=(
130140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
130150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($Symbol, 2),
130160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($OverriddenMethod, 2),
1301774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($Symbol, 2));
130180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
130231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
130241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check all removed exported symbols
130251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
13026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
130280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{2}{$Symbol}
130290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$Symbol}{"Header"})
130300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check removed symbol
130310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
130321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
130341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip private methods
130351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
130361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13037850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
130381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
130391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
130411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{1}{$Symbol}{"Override"})
130421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1304362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
1304462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{1}{$Cid}{"Name"};
13045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$OverriddenMethod}
130460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$OverriddenMethod}{"Virt"})
130470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{2}{$AffectedClass_Name})
130490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in newer version
130500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($CompleteSignature{1}{$Symbol}{"Class"}, 1))
130510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
130520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Overridden_Virtual_Method_B"}{$tr_name{$OverriddenMethod}}}=(
130530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
130540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($OverriddenMethod, 1),
130550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($Symbol, 1),
1305674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($OverriddenMethod, 1));
130570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
130611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
130626fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        and $OStarget eq "windows")
13063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register the reason of symbol name change
1306462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $NewSym = $mangled_name{2}{$tr_name{$Symbol}})
13065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1306662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($AddedInt{$Level}{$NewSym})
13067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1306862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Static"} ne $CompleteSignature{2}{$NewSym}{"Static"})
13069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1307062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Static"})
130711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
130721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Static"}{$tr_name{$Symbol}}}=(
130731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
130741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1307562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
130771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
130781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Static"}{$tr_name{$Symbol}}}=(
130801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
130811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1308262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1308562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Virt"} ne $CompleteSignature{2}{$NewSym}{"Virt"})
13086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1308762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Virt"})
130881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
130891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Virtual"}{$tr_name{$Symbol}}}=(
130901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
130911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1309262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
130941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
130951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Virtual"}{$tr_name{$Symbol}}}=(
130971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
130981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1309962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1310262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId1 = $CompleteSignature{1}{$Symbol}{"Return"};
1310362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId2 = $CompleteSignature{2}{$NewSym}{"Return"};
1310462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName1 = $TypeInfo{1}{$RTId1}{"Name"};
1310562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName2 = $TypeInfo{2}{$RTId2}{"Name"};
1310662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($RTName1 ne $RTName2)
13107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Symbol_Changed_Return";
131091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"Data"}) {
13110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Global_Data_Symbol_Changed_Type";
13111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
131121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{$tr_name{$Symbol}}}=(
131131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1311462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Old_Type"=>$RTName1,
1311562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Type"=>$RTName2,
131161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1311762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
131221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
131241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Prefix = get_symbol_prefix($Symbol, 1);
13125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my @Overloads = sort keys(%{$AddedOverloads{$Prefix}})
131261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $AddedOverloads{$Prefix}{get_symbol_suffix($Symbol, 1)})
13127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # changed signature: params, "const"-qualifier
1312862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NewSym = $AddedOverloads{$Prefix}{$Overloads[0]};
131291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($CompleteSignature{1}{$Symbol}{"Constructor"})
131301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13131f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(C[1-2][EI])/)
13132989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $CtorType = $1;
13134f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(C[1-2][EI])/$CtorType/g;
13135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
131371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                elsif($CompleteSignature{1}{$Symbol}{"Destructor"})
131381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13139f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(D[0-2][EI])/)
13140989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $DtorType = $1;
13142f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(D[0-2][EI])/$DtorType/g;
13143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $NS1 = $CompleteSignature{1}{$Symbol}{"NameSpace"};
1314662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NS2 = $CompleteSignature{2}{$NewSym}{"NameSpace"};
13147dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if((not $NS1 and not $NS2) or ($NS1 and $NS2 and $NS1 eq $NS2))
13148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # from the same class and namespace
131491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Const"}
1315062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Const"})
13151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "const" to non-"const"
13152fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Const"}{$tr_name{$Symbol}}}=(
1315362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Type_Name"=>$TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"},
131541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1315562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
131561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1315762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
131591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Const"}
1316062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Const"})
13161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"const" to "const"
131620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Const"}{$tr_name{$Symbol}}}=(
131631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1316462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
131651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1316662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
131681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Volatile"}
1316962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Volatile"})
13170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "volatile" to non-"volatile"
13171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Volatile"}{$tr_name{$Symbol}}}=(
131731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1317462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
131751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1317662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
131781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Volatile"}
1317962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Volatile"})
13180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"volatile" to "volatile"
131810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Volatile"}{$tr_name{$Symbol}}}=(
131821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1318362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
131841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1318562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1318762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(get_symbol_suffix($Symbol, 0) ne get_symbol_suffix($NewSym, 0))
13188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # params list
131891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Symbol_Changed_Parameters"}{$tr_name{$Symbol}}}=(
131901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1319162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
131921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1319362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
131991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
132001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # checking symbols
13201f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $CurrentSymbol = $Symbol;
13202f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
132031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
132041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
132051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
132061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
132071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
132091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary
132101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $SV)
132111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # symbol without version
132121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $VSym = $SymVer{1}{$Symbol})
132131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # the symbol is linked with versioned symbol
132141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{2}{$VSym}{"MnglName"})
132151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # show report for symbol@ver only
132161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
132171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
132181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not link_symbol($VSym, 2, "-Deps"))
132191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed version: sym@v1 to sym@v2
132201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                      # do NOT show report for symbol
132211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
132221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
13223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PSymbol = $Symbol;
132271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source"
132281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and my $S = $SourceReplacement{$Symbol})
132291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # take a source-compatible replacement function
132301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $PSymbol = $S;
132311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
13233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # private symbols
13234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
132371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not defined $CompleteSignature{2}{$PSymbol})
132381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no info
132391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"MnglName"}
132421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"MnglName"})
132431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no mangled name
13244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
132471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"Header"})
13248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # without a header
13249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
132529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"PureVirt"}
132539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"PureVirt"})
132549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became pure
132559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
132569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
132579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
132589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"PureVirt"})
132599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became non-pure
132609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
132619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
132629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
132639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level))
132649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
132659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
132669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
132679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($PSymbol, 2, "Affected + InlineVirt", $Level))
132689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
132699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
132709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
132719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1327262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.13") and checkDump(2, "2.13"))
132730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
132740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"}
132750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Data"})
132760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value1 = $CompleteSignature{1}{$Symbol}{"Value"};
132780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value2 = $CompleteSignature{2}{$PSymbol}{"Value"};
132790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $Value1)
132800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
132810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value1 = showVal($Value1, $CompleteSignature{1}{$Symbol}{"Return"}, 1);
132820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $Value2)
132830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
132840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        $Value2 = showVal($Value2, $CompleteSignature{2}{$PSymbol}{"Return"}, 2);
132850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($Value1 ne $Value2)
132860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
132870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Global_Data_Value_Changed"}{""}}=(
132880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Old_Value"=>$Value1,
132890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "New_Value"=>$Value2,
132900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Target"=>get_Signature($Symbol, 1)  );
132910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
132920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
132930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
132940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
132950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
13296850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
132970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Private"})
132980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
132990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Private"}{""}}=(
133000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
133010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
133020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(not $CompleteSignature{1}{$Symbol}{"Protected"}
133030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"Protected"})
133040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
133050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Protected"}{""}}=(
133060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
133070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
133080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($CompleteSignature{1}{$Symbol}{"Protected"}
133090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"Protected"})
133100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
133110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Public"}{""}}=(
133120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
133130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
133140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking virtual table
133161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        mergeVirtualTables($Symbol, $Level);
133171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
13318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($COMPILE_ERRORS)
13319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # if some errors occurred at the compiling stage
13320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # then some false positives can be skipped here
133211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Data"} and $CompleteSignature{2}{$PSymbol}{"Data"}
1332262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $GlobalDataObject{2}{$Symbol})
13323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # missed information about parameters in newer version
13324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1332662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"} and not $GlobalDataObject{1}{$Symbol}
133271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Data"})
133289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # missed information about parameters in older version
13329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
13333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking attributes
133341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Static"}
133359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
133369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
133371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Static"}{""}}=(
133381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
133391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif(not $CompleteSignature{2}{$PSymbol}{"Static"}
133429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
133439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
13344fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Static"}{""}}=(
133451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
133461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($CompleteSignature{1}{$Symbol}{"Virt"} and $CompleteSignature{2}{$PSymbol}{"Virt"})
133491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or ($CompleteSignature{1}{$Symbol}{"PureVirt"} and $CompleteSignature{2}{$PSymbol}{"PureVirt"}))
13350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative position of virtual and pure virtual methods
133511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
13352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13353dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Symbol}{"RelPos"} and defined $CompleteSignature{2}{$PSymbol}{"RelPos"}
13354dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"RelPos"}!=$CompleteSignature{2}{$PSymbol}{"RelPos"})
13355dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # top-level virtual methods only
133561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Class_Id = $CompleteSignature{1}{$Symbol}{"Class"};
1335762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Class_Name = $TypeInfo{1}{$Class_Id}{"Name"};
13358dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{1}{$Class_Name} and defined $VirtualTable{2}{$Class_Name}
13359dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    and $VirtualTable{1}{$Class_Name}{$Symbol}!=$VirtualTable{2}{$Class_Name}{$Symbol})
133601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # check the absolute position of virtual method (including added and removed methods)
1336162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %Class_Type = get_Type($Class_Id, 1);
133621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Virtual_Method_Position";
133631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
133641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Pure_Virtual_Method_Position";
133651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
133661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isUsedClass($Class_Id, 1, $Level))
13367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
133681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            my @Affected = ($Symbol, keys(%{$OverriddenMethods{1}{$Symbol}}));
133699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            foreach my $ASymbol (@Affected)
133701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            {
133719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
133729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                    next;
133739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                }
133749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$MnglName}}}=(
133751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Type_Name"=>$Class_Type{"Name"},
133761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Old_Value"=>$CompleteSignature{1}{$Symbol}{"RelPos"},
133771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Value"=>$CompleteSignature{2}{$PSymbol}{"RelPos"},
1337874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                                    "Target"=>get_Signature($Symbol, 1));
133791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
133801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $VTableChanged_M{$Class_Type{"Name"}} = 1;
13381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
133871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{2}{$PSymbol}{"PureVirt"})
13388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT check type changes in pure virtuals
13389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13391ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
133921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/
133931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})==keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C/C++: changes in parameters
133951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking parameters
13397ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 1);
13398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
13401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C: added/removed parameters
134021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking added parameters
13404dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
1340562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType2_Name = $TypeInfo{2}{$PType2_Id}{"Name"};
1340662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType2_Name eq "...");
1340762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1340862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName_Old = (defined $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos})?$CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"}:"";
13409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_Prev = "-1";
1341062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added unnamed parameter ( pN )
1341262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 1);
1341362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 2);
13414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions1==-1 or $#Positions2>$#Positions1) {
13415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_Prev = "lost";
13416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
1341962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ParamPos_Prev = find_ParamPair_Pos_byName($PName, $Symbol, 1);
13420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_Prev eq "lost")
13422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
134231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Added_Parameter";
1342662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Added_Unnamed_Parameter";
13428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
134290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1343062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Target"=>$PName,
13431f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1343262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType2_Name,
134331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
13436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13437f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType2_Id, $TypeInfo{2});
1343862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
13439f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{1});
1344062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType2_Name eq $TypeInfo{1}{$PairType_Id}{"Name"})
1344162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_Old, $Symbol, 2) eq "lost")
13442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
1344362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName_Old!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
134450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
1344662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Target"=>$PName_Old,
13447f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1344862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType2_Name,
1344962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Old_Value"=>$PName_Old,
1345062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "New_Value"=>$PName,
134511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Added_Middle_Parameter";
1345762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Added_Middle_Unnamed_Parameter";
13459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
134600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1346162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Target"=>$PName,
13462f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1346362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType2_Name,
134641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
134691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # check relevant parameters
13471dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
134721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $ParamName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # FIXME: find relevant parameter by name
134741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})
13475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13476dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
134771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ParamName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1347862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TypeInfo{1}{$PType1_Id}{"Name"} eq $TypeInfo{2}{$PType2_Id}{"Name"}
1347962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    or ($ParamName1!~/\Ap\d+\Z/i and $ParamName1 eq $ParamName2)) {
13480ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 0);
13481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
134841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking removed parameters
13486dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
1348762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType1_Name = $TypeInfo{1}{$PType1_Id}{"Name"};
1348862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType1_Name eq "...");
13489ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13490ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName_New = (defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})?$CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"}:"";
13491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_New = "-1";
13492ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed unnamed parameter ( pN )
1349462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 1);
1349562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 2);
13496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions2==-1 or $#Positions2<$#Positions1) {
13497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_New = "lost";
13498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13501ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    $ParamPos_New = find_ParamPair_Pos_byName($PName, $Symbol, 2);
13502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_New eq "lost")
13504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
135051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}})-1)
13506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Removed_Parameter";
13508ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Removed_Unnamed_Parameter";
13510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
135110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13512ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            "Target"=>$PName,
13513f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1351462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType1_Name,
135151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
135171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($ParamPos<keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13519f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType1_Id, $TypeInfo{1});
1352062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
13521f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{2});
1352262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType1_Name eq $TypeInfo{2}{$PairType_Id}{"Name"})
13523ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_New, $Symbol, 1) eq "lost")
13524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13525ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName_New!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
135270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
13528ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Target"=>$PName,
13529f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1353062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType1_Name,
13531ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Old_Value"=>$PName,
13532ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "New_Value"=>$PName_New,
135331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Removed_Middle_Parameter";
13539ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Removed_Middle_Unnamed_Parameter";
13541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
135420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13543ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                "Target"=>$PName,
13544f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1354562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType1_Name,
135461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking return type
135531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType1_Id = $CompleteSignature{1}{$Symbol}{"Return"};
135541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType2_Id = $CompleteSignature{2}{$PSymbol}{"Return"};
13555f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %RC_SubProblems = detectTypeChange($ReturnType1_Id, $ReturnType2_Id, "Return", $Level);
13556fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13557f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubProblemType (keys(%RC_SubProblems))
13558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13559f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $New_Value = $RC_SubProblems{$SubProblemType}{"New_Value"};
13560f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Old_Value = $RC_SubProblems{$SubProblemType}{"Old_Value"};
13561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %ProblemTypes = ();
13562f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13563fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type_And_Size") {
13566fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_And_Size"} = 1;
13567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_Format") {
13569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_Format"} = 1;
13570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13571fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
13572fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type"} = 1;
13573fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13574fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13575fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13576fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13577fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13578fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13580fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RR = removedQual($Old_Value, $New_Value, "const"))
13581fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # const to non-const
13582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RR==2) {
13583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Removed_Const"} = 1;
13584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13586fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Non_Const"} = 1;
13587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13590fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    elsif(my $RA = addedQual($Old_Value, $New_Value, "const"))
13591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # non-const to const
13592fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13593fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Added_Const"} = 1;
13594fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13595fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13596fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Const"} = 1;
13597fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13598fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13601fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else
13603fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(checkDump(1, "2.6") and checkDump(2, "2.6"))
13610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(addedQual($Old_Value, $New_Value, "volatile"))
13612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Value_Became_Volatile"} = 1;
13614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Level ne "Source"
13615fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13616fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                $ProblemTypes{"Return_Type"} = 1;
13617fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13618fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13619fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13620fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RA = addedQual($Old_Value, $New_Value, "const"))
136219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
13622fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13623fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Added_Const"} = 1;
13624fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13625fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13626fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Const"} = 1;
13627fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13628fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Level ne "Source"
13629fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13630fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type"} = 1;
13631fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13635f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Level eq "Binary"
13636f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and not $CompleteSignature{1}{$Symbol}{"Data"})
13637f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
13638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my ($Arch1, $Arch2) = (getArch(1), getArch(2));
13639f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Arch1 eq "unknown" or $Arch2 eq "unknown")
13640f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                { # if one of the architectures is unknown
13641f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    # then set other arhitecture to unknown too
13642f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    ($Arch1, $Arch2) = ("unknown", "unknown");
13643f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13644f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my (%Conv1, %Conv2) = ();
13645fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UseConv_Real{1}{"R"} and $UseConv_Real{2}{"R"})
13646f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13647f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Real($CompleteSignature{1}{$Symbol});
13648f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Real($CompleteSignature{2}{$PSymbol});
13649f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13650f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                else
13651f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13652f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Model($CompleteSignature{1}{$Symbol}, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
13653f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Model($CompleteSignature{2}{$PSymbol}, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
13654f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13655f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13656f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($SubProblemType eq "Return_Type_Became_Void")
13657f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13658f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13659f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13660f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack") {
13661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Stack_Layout"} = 1;
13662f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13663f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv1{"Hidden"}) {
13664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Register"} = 1;
13665f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13666f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13667f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13668f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_From_Void")
13669f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13670f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13671f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13672f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv2{"Method"} eq "stack") {
13673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Stack_Layout"} = 1;
13674f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13675f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv2{"Hidden"}) {
13676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Register"} = 1;
13677f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13678f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13679f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13680f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type"
13681f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13682f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13683f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13684f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Method"} ne $Conv2{"Method"})
13685f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13686f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack")
13687f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        { # returns in a register instead of a hidden first parameter
13688fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Stack_To_Register"} = 1;
13689f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13690f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        else {
13691fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Register_To_Stack"} = 1;
13692f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13693f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13694f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    else
13695f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13696f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "reg")
13697f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
13698f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            if($Conv1{"Registers"} ne $Conv2{"Registers"})
13699f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            {
13700f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if($Conv1{"Hidden"}) {
13701fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Was_Hidden_Parameter"} = 1;
13702f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13703f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                elsif($Conv2{"Hidden"}) {
13704fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Became_Hidden_Parameter"} = 1;
13705f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13706f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                else {
13707fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register"} = 1;
13708f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13709f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            }
13710f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13711f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13712f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13713f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
13714fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not keys(%ProblemTypes))
13716fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # default
13717fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $ProblemTypes{$SubProblemType} = 1;
13718fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13720fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $ProblemType (keys(%ProblemTypes))
13721fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # additional
13722f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $CompatProblems{$Level}{$Symbol}{$ProblemType}{"retval"} = $RC_SubProblems{$SubProblemType};
137239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
13724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ReturnType1_Id and $ReturnType2_Id)
13726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @RecurTypes = ();
13728f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Sub_SubProblems = mergeTypes($ReturnType1_Id, $ReturnType2_Id, $Level);
13729f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13730f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $AddProblems = {};
13731fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13732fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13733fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13734fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Binary")
13735fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
13736fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(get_PLevel($ReturnType1_Id, 1)==0)
13737fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
1373833ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        if(defined $Sub_SubProblems->{"DataType_Size"})
13739fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        { # add "Global_Data_Size" problem
13740d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1374133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            foreach my $Loc (keys(%{$Sub_SubProblems->{"DataType_Size"}}))
1374233ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                            {
1374333ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                if(index($Loc,"->")==-1)
13744d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                {
13745d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    if($Loc eq $Sub_SubProblems->{"DataType_Size"}{$Loc}{"Type_Name"})
13746d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    {
13747d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        $AddProblems->{"Global_Data_Size"}{$Loc} = $Sub_SubProblems->{"DataType_Size"}{$Loc}; # add a new problem
13748d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                        last;
13749d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                    }
1375033ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                                }
13751fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13752fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13753fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13754f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if(not defined $AddProblems->{"Global_Data_Size"})
13755fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(defined $GlobalDataObject{1}{$Symbol}
13757fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        and defined $GlobalDataObject{2}{$Symbol})
13758fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Size = $GlobalDataObject{1}{$Symbol};
13760fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Size = $GlobalDataObject{2}{$Symbol};
13761fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Old_Size!=$New_Size)
13762fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            {
13763f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $AddProblems->{"Global_Data_Size"}{"retval"} = {
13764fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "Old_Size"=>$Old_Size*$BYTE_SIZE,
13765f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "New_Size"=>$New_Size*$BYTE_SIZE };
13766fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13768fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13771f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13772f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$AddProblems}))
13773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13774f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$AddProblems->{$SubProblemType}}))
13775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1377633ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1377733ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1377833ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1377933ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13780f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $AddProblems->{$SubProblemType}{$SubLocation};
13781f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
13782f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
13783f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13784f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13785f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
13786f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
13787f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                {
1378833ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    my $NewLocation = "retval";
1378933ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    if($SubLocation and $SubLocation ne "retval") {
1379033ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                        $NewLocation = "retval->".$SubLocation;
1379133ca7f1969ba09070b843a589dc2838d30343c7bAndrey Ponomarenko                    }
13792f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
13793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking object type
1379862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId1 = $CompleteSignature{1}{$Symbol}{"Class"};
1379962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId2 = $CompleteSignature{2}{$PSymbol}{"Class"};
1380062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ObjTId1 and $ObjTId2
138011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"})
13802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1380362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr1_Id = getTypeIdByName($TypeInfo{1}{$ObjTId1}{"Name"}."*const", 1);
1380462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr2_Id = getTypeIdByName($TypeInfo{2}{$ObjTId2}{"Name"}."*const", 2);
13805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ThisPtr1_Id and $ThisPtr2_Id)
13806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @RecurTypes = ();
13808f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Sub_SubProblems = mergeTypes($ThisPtr1_Id, $ThisPtr2_Id, $Level);
13809f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13811f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
13812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NewLocation = ($SubLocation)?"this->".$SubLocation:"this";
13814f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
13815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
138201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
138211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeVTables($Level);
138221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
13823850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompatProblems{$Level}})) {
13824850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
13825850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
13826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
138280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub rmQuals($$)
138290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
138310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
138320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
138330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
138340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Qual eq "all")
138350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # all quals
138360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Qual = "const|volatile|restrict";
138370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1383862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~s/\b$Qual\b//) {
138399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Value = formatName($Value, "T");
138400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
138410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
138420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
138440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub cmpBTypes($$$$)
138450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($T1, $T2, $V1, $V2) = @_;
138470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T1 = uncover_typedefs($T1, $V1);
138480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T2 = uncover_typedefs($T2, $V2);
138490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return (rmQuals($T1, "all") eq rmQuals($T2, "all"));
138500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
138520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub addedQual($$$)
138530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
13855fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($New_Value, $Old_Value, 2, 1, $Qual);
138560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
138581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub removedQual($$$)
13859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
138601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
13861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($Old_Value, $New_Value, 1, 2, $Qual);
138620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
138630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13864fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removedQual_I($$$$$)
138650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $V1, $V2, $Qual) = @_;
138670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Old_Value = uncover_typedefs($Old_Value, $V1);
138680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $New_Value = uncover_typedefs($New_Value, $V2);
138690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Old_Value eq $New_Value)
138700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # equal types
13871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
13872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1387362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Old_Value!~/\b$Qual\b/)
138740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # without a qual
138750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 0;
138760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1387762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($New_Value!~/\b$Qual\b/)
138780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # became non-qual
138790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
138800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
138810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    else
138820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
138830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ1 = getQualModel($Old_Value, $Qual);
138840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ2 = getQualModel($New_Value, $Qual);
138850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        foreach (0 .. $#BQ1)
138860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # removed qual
138870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BQ1[$_]==1
138880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BQ2[$_]!=1)
138890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
138900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 2;
138910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
13892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
13895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
138970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualModel($$)
138980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
138990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
139000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
139010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
139020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # cleaning
1390562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~/(\w+)/ and $1 ne $Qual) {
1390662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Value=~s/\b$1\b//g;
139070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Value=~s/[^\*\&\w]+//g;
139090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # modeling
139110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int*const*const == 011
139120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int**const == 001
139130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Model = ();
139140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Elems = split(/[\*\&]/, $Value);
139150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not @Elems) {
139160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return (0);
139170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach (@Elems)
139190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
139200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($_ eq $Qual) {
139210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 1);
139220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
139230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
139240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 0);
139250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
139260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return @Model;
139290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
139300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
139314b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %StringTypes = map {$_=>1} (
139324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char*",
139334b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const*"
139344b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
139354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
139364b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %CharTypes = map {$_=>1} (
139374b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char",
139384b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const"
139394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
139404b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
139410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showVal($$$)
139420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
139430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $TypeId, $LibVersion) = @_;
13944f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
13945a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $TName = uncover_typedefs($PureType{"Name"}, $LibVersion);
1394601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(substr($Value, 0, 2) eq "_Z")
1394701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
1394801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Unmangled = $tr_name{$Value}) {
1394901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Unmangled;
1395001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1395101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
139524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $StringTypes{$TName} or $TName=~/string/i)
139530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # strings
139540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\"$Value\"";
139550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139564b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $CharTypes{$TName})
139570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # characters
139580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\'$Value\'";
139590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
139604b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($Value eq "")
139614b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    { # other
139624b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return "\'\'";
139634b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
139640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
139650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
139660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13967fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub getRegs($$$)
13968fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
13969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Symbol, $Pos) = @_;
13970fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13971fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}{"Reg"})
13972fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
13973fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %Regs = ();
13974fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Elem (sort keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}}))
13975fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
13976ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if($Elem=~/\A$Pos([\.\+]|\Z)/) {
13977fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Regs{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}{$Elem}} = 1;
13978fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
13980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return join(", ", sort keys(%Regs));
13982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
13983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13984fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return undef;
13985fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
13986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13987ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenkosub mergeParameters($$$$$$)
13988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13989ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    my ($Symbol, $PSymbol, $ParamPos1, $ParamPos2, $Level, $ChkRnmd) = @_;
139900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Symbol) {
139910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
139920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
13993dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"type"};
13994dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"name"};
13995dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"type"};
13996dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"name"};
139970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $PType1_Id
139980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    or not $PType2_Id) {
139990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
140000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14001ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14002f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
14003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # do not merge "this"
14004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($PName1 eq "this" or $PName2 eq "this") {
14005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return;
14006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
14007ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    }
14008ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
1400962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($PType1_Id, 1);
1401062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($PType2_Id, 2);
1401152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1401252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %PureType1 = get_PureType($PType1_Id, $TypeInfo{1});
1401352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1401462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType1 = get_BaseType($PType1_Id, 1);
1401562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType2 = get_BaseType($PType2_Id, 2);
1401652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
140170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Parameter_Location = ($PName1)?$PName1:showPos($ParamPos1)." Parameter";
14018ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
140191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
140201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
1402162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.6.1") and checkDump(2, "2.6.1"))
140221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # "reg" attribute added in ACC 1.95.1 (dump 2.6.1 format)
140231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
140241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
140251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
140261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Non_Register"}{$Parameter_Location}}=(
14027dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14028f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
140291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
140301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif(not $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
140311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
140321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
140331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Register"}{$Parameter_Location}}=(
14034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14035f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
140361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
14037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $UsedDump{1}{"DWARF"}
14040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and defined $UsedDump{2}{"DWARF"})
14041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "3.0") and checkDump(2, "3.0"))
14043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Old_Regs = getRegs(1, $Symbol, $ParamPos1);
14045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $New_Regs = getRegs(2, $PSymbol, $ParamPos2);
14046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Old_Regs and $New_Regs)
14047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Regs ne $New_Regs)
14049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14050fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Register"}{$Parameter_Location}}=(
14051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14052f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Old_Value"=>$Old_Regs,
14054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Regs  );
14055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14057fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Old_Regs and not $New_Regs)
14058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14059fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_From_Register"}{$Parameter_Location}}=(
14060fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$PName1,
14061f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14062fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Old_Regs  );
14063fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14064fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(not $Old_Regs and $New_Regs)
14065fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14066fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_To_Register"}{$Parameter_Location}}=(
14067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$PName1,
14068f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14069fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$New_Regs  );
14070fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14071fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if((my $Old_Offset = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"offset"}) ne ""
14072fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and (my $New_Offset = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"offset"}) ne "")
14073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Offset ne $New_Offset)
14075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14076f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start1 = $CompleteSignature{1}{$Symbol}{"Param"}{0}{"offset"};
14077f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start2 = $CompleteSignature{2}{$Symbol}{"Param"}{0}{"offset"};
14078f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14079f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $Old_Offset = $Old_Offset - $Start1;
14080f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $New_Offset = $New_Offset - $Start2;
14081f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14082f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if($Old_Offset ne $New_Offset)
14083f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
14084f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Offset"}{$Parameter_Location}}=(
14085f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Target"=>$PName1,
14086f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14087f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Old_Value"=>$Old_Offset,
14088f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "New_Value"=>$New_Offset  );
14089f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
14090fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14091fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14092fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14093fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14095177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(checkDump(1, "2.0") and checkDump(2, "2.0")
14096177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $UsedDump{1}{"V"} ne "3.1" and $UsedDump{2}{"V"} ne "3.1")
14097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # "default" attribute added in ACC 1.22 (dump 2.0 format)
14098177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      # broken in 3.1, fixed in 3.2
140990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_Old = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"default"};
141000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_New = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"default"};
1410162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1410262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and checkDump(2, "2.13"))
141030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
141040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_Old and defined $Value_New)
141050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
1410652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Name"} eq "bool"
141070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $Value_Old eq "false" and $Value_New eq "0")
141080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # int class::method ( bool p = 0 );
141090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # old ABI dumps: "false"
141100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # new ABI dumps: "0"
141110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value_Old = "0";
141120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
14113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1411501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not checkDump(1, "2.18")
1411601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and checkDump(2, "2.18"))
1411701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # support for old ABI dumps
1411801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not defined $Value_Old
1411901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and substr($Value_New, 0, 2) eq "_Z") {
1412001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Value_Old = $Value_New;
1412101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
1412201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
141230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Value_Old)
14124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
141250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_Old = showVal($Value_Old, $PType1_Id, 1);
141260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_New)
14127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
141280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Value_New = showVal($Value_New, $PType2_Id, 2);
141290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Value_Old ne $Value_New)
141300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # FIXME: how to distinguish "0" and 0 (NULL)
141311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Changed"}{$Parameter_Location}}=(
14132dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Target"=>$PName1,
14133f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "Old_Value"=>$Value_Old,
141350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "New_Value"=>$Value_New  );
14136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
141401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Removed"}{$Parameter_Location}}=(
141410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>$PName1,
14142f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Old_Value"=>$Value_Old  );
14144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
141460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(defined $Value_New)
141470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
141480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_New = showVal($Value_New, $PType2_Id, 2);
141490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Added"}{$Parameter_Location}}=(
141500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>$PName1,
14151f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
141520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "New_Value"=>$Value_New  );
141530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
14154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14155ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14156ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    if($ChkRnmd)
14157ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    {
14158ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($PName1 and $PName2 and $PName1 ne $PName2
14159ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PType1_Id!=-1 and $PType2_Id!=-1
14160ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PName1!~/\Ap\d+\Z/ and $PName2!~/\Ap\d+\Z/)
14161ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # except unnamed "..." value list (Id=-1)
14162ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos1)." Parameter"}}=(
14163ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Target"=>$PName1,
14164f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14165ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14166ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Old_Value"=>$PName1,
14167ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Value"=>$PName2,
14168ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Signature"=>get_Signature($Symbol, 2)  );
14169ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
14170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14171ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type change (replace)
14173dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my %SubProblems = detectTypeChange($PType1_Id, $PType2_Id, "Parameter", $Level);
14174f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add new problems, remove false alarms
14177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14179fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14180fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # quals
14181fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SubProblemType eq "Parameter_Type"
14182fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_And_Size"
14183fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_Format")
14184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1418562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14187fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(addedQual($Old_Value, $New_Value, "restrict")) {
141880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Restrict"}} = %{$SubProblems{$SubProblemType}};
141891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(removedQual($Old_Value, $New_Value, "restrict")) {
14191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Restrict"}} = %{$SubProblems{$SubProblemType}};
14192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(removedQual($Old_Value, $New_Value, "volatile")) {
14197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Volatile"}} = %{$SubProblems{$SubProblemType}};
14198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2{"Type"} eq "Const" and $BaseType2{"Name"} eq $Type1{"Name"}
14201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # int to "int const"
14203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif($Type1{"Type"} eq "Const" and $BaseType1{"Name"} eq $Type2{"Name"}
14206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "int const" to int
14208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14210fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
14211fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # "const" to non-"const"
14212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($RR==2) {
14213fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Removed_Const"}} = %{$SubProblems{$SubProblemType}};
14214fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14215fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
14216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Const"}} = %{$SubProblems{$SubProblemType}};
14217fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14222fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Level eq "Source")
14223fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14224fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14225fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14227fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14228fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SubProblemType eq "Parameter_Type")
14230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
14232fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($SubProblems{$SubProblemType});
14233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14236fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14237fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify/register problems
14240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14242f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $New_Size = $SubProblems{$SubProblemType}{"New_Size"};
14243f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $Old_Size = $SubProblems{$SubProblemType}{"Old_Size"};
14244fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NewProblemType = $SubProblemType;
14246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Old_Value eq "..." and $New_Value ne "...")
14247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "..." to "int"
14248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos1==0)
14249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $NewProblemType = "Parameter_Became_Non_VaList";
14253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($New_Value eq "..." and $Old_Value ne "...")
14255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "int" to "..."
14256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos2==0)
14257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $NewProblemType = "Parameter_Became_VaList";
14261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
142621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($Level eq "Binary" and ($SubProblemType eq "Parameter_Type_And_Size"
14263f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type" or $SubProblemType eq "Parameter_Type_Format"))
14264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Arch1, $Arch2) = (getArch(1), getArch(2));
14266f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Arch1 eq "unknown"
14267f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            or $Arch2 eq "unknown")
14268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if one of the architectures is unknown
14269f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko              # then set other arhitecture to unknown too
14270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($Arch1, $Arch2) = ("unknown", "unknown");
14271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14272f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my (%Conv1, %Conv2) = ();
14273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UseConv_Real{1}{"P"} and $UseConv_Real{2}{"P"})
14274f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # real
14275f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Real($CompleteSignature{1}{$Symbol}, $ParamPos1);
14276f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Real($CompleteSignature{2}{$Symbol}, $ParamPos2);
14277f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14278f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            else
14279f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # model
14280f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Model($CompleteSignature{1}{$Symbol}, $ParamPos1, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
14281f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Model($CompleteSignature{2}{$Symbol}, $ParamPos2, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
14282f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14283f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Conv1{"Method"} eq $Conv2{"Method"})
14284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14285f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack")
14286f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14287f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Old_Size ne $New_Size) { # FIXME: isMemPadded, getOffset
14288f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Stack";
14289f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14291f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "reg")
14292f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14293f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Registers"} ne $Conv2{"Registers"}) {
14294f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Register";
14295f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14300f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack") {
14301f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Stack_To_Register";
14302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14303f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "register") {
14304f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Register_To_Stack";
14305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14307f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"Old_Reg"} = $Conv1{"Registers"};
14308f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"New_Reg"} = $Conv2{"Registers"};
14309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}=(
14311dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            "Target"=>$PName1,
14312f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            "New_Signature"=>get_Signature($Symbol, 2) );
143141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
14315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14316f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @RecurTypes = ();
14318f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type definition changes
14320f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Sub_SubProblems = mergeTypes($PType1_Id, $PType2_Id, $Level);
14321f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14323f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewProblemType = $SubProblemType;
14326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubProblemType eq "DataType_Size")
14327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1432852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if($PureType1{"Type"}!~/\A(Pointer|Ref)\Z/ and $SubLocation!~/\-\>/)
14329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # stack has been affected
14330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $NewProblemType = "DataType_Size_And_Stack";
14331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewLocation = ($SubLocation)?$Parameter_Location."->".$SubLocation:$Parameter_Location;
14334f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byName($$$)
14340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
143411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
143421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
143441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
143451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"name"} eq $Name)
14346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $ParamPos;
14348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
14351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byTypeAndPos($$$$$)
14354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
143551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TypeName, $MediumPos, $Order, $Symbol, $LibVersion) = @_;
14356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Positions = ();
143571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "backward" and $ParamPos>$MediumPos);
14360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "forward" and $ParamPos<$MediumPos);
143611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
143621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"type"};
1436362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$PTypeId}{"Name"} eq $TypeName) {
14364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Positions, $ParamPos);
14365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Positions;
14368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeIdByName($$)
14371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14372e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
14373e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    return $TName_Tid{$LibVersion}{formatName($TypeName, "T")};
14374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
143768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes($$$)
143778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
143788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]}) {
143798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]};
143808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
143818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($_[0], $_[1], \@RecurTypes_Diff))
143828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip recursive declarations
143838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
143848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
143858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
143868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($_[0], $_[1], \@RecurTypes_Diff);
143878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Diff = diffTypes_I(@_);
143888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pop(@RecurTypes_Diff);
143898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
143908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]} = $Diff);
143918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
143928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
143938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes_I($$$)
14394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
143951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
143968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14397f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14398f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
143998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
14401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # equal types
14402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
144049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Type1_Pure{"Name"} eq "void")
144059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # from void* to something
144069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return 0;
144079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
14408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"}=~/\*/
14409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type2_Pure{"Name"}=~/\*/)
14410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compared in detectTypeChange()
14411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
144138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %FloatType = map {$_=>1} (
14415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "float",
14416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "double",
14417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "long double"
14418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
14419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14420fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T1 = $Type1_Pure{"Type"};
14421fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T2 = $Type2_Pure{"Type"};
14422fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Struct"
14424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Class")
14425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T2 = "Struct";
14427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Class"
14430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Struct")
14431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T1 = "Struct";
14433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 ne $T2)
14436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
14437fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic"
14438fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T2 eq "Enum")
14439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "int" to "enum"
14440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T2 eq "Intrinsic"
14443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T1 eq "Enum")
14444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "enum" to "int"
14445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
14448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # union to struct
14449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
14450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
14451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
14454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic")
14456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($FloatType{$Type1_Pure{"Name"}}
14458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $FloatType{$Type2_Pure{"Name"}})
14459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "float" to "double"
14460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # "float" to "int"
144611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source")
144621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Safe
144631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 0;
144641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
144651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
144661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 1;
144671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T1=~/Class|Struct|Union|Enum/)
14471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs1 = keys(%{$Type1_Pure{"Memb"}});
14473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs2 = keys(%{$Type2_Pure{"Memb"}});
14474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not @Membs1
14475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            or not @Membs2)
14476570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # private
14477570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return 0;
14478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
14479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($#Membs1!=$#Membs2)
14480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different number of elements
14481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
14482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($T1 eq "Enum")
14484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
14486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # compare elements by name and value
14487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"}
14488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or $Type1_Pure{"Memb"}{$Pos}{"value"} ne $Type2_Pure{"Memb"}{$Pos}{"value"})
14489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # different names
14490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return 1;
14491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
144978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
144981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source")
144991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
145001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"})
145011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # different names
145021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            return 1;
145031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
145041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
145058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT1 = %{$TypeInfo{1}{$Type1_Pure{"Memb"}{$Pos}{"type"}}};
145078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT2 = %{$TypeInfo{2}{$Type2_Pure{"Memb"}{$Pos}{"type"}}};
145088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($MT1{"Name"} ne $MT2{"Name"}
145108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    or isAnon($MT1{"Name"}) or isAnon($MT2{"Name"}))
145118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
145128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL1 = get_PLevel($MT1{"Tid"}, 1);
145138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL2 = get_PLevel($MT2{"Tid"}, 2);
145148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($PL1 ne $PL2)
145168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different pointer level
145178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
145188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
145198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        # compare base types
145218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT1 = get_BaseType($MT1{"Tid"}, 1);
145228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT2 = get_BaseType($MT2{"Tid"}, 2);
145238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
145248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(diffTypes($BT1{"Tid"}, $BT2{"Tid"}, $Level))
145258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different types
145268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
145278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
145288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
14529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
145328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
145338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
145348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            # TODO: arrays, etc.
145358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
14536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
145401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectTypeChange($$$$)
14541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Prefix, $Level) = @_;
14543dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Type1_Id or not $Type2_Id) {
14544dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return ();
14545dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LocalProblems = ();
1454762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1454862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
14549f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14550f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
14551f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Base = ($Type1_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type1_Pure{"Tid"}, $TypeInfo{1}):get_BaseType($Type1_Id, 1);
14552f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Base = ($Type2_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type2_Pure{"Tid"}, $TypeInfo{2}):get_BaseType($Type2_Id, 2);
1455374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1455462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type1_PLevel = get_PLevel($Type1_Id, 1);
1455562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type2_PLevel = get_PLevel($Type2_Id, 2);
14556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1{"Name"} or not $Type2{"Name"});
14557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Base{"Name"} or not $Type2_Base{"Name"});
14558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($Type1_PLevel eq "" or $Type2_PLevel eq "");
14559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Base{"Name"} ne $Type2_Base{"Name"}
14560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and ($Type1{"Name"} eq $Type2{"Name"} or ($Type1_PLevel>=1 and $Type1_PLevel==$Type2_PLevel
14561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Base{"Name"} ne "void" and $Type2_Base{"Name"} ne "void")))
14562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base type change
145639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Type1{"Name"} eq $Type2{"Name"})
145649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
145659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Type1{"Type"} eq "Typedef" and $Type2{"Type"} eq "Typedef")
145669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # will be reported in mergeTypes() as typedef problem
145679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return ();
145689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
145699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
145709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
145719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(%Typedef_1 and %Typedef_2)
145729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
145739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Typedef_1{"Name"} eq $Typedef_2{"Name"}
145749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef")
145759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # const Typedef
145769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    return ();
145779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
145789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
14579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1_Base{"Name"}!~/anon\-/ and $Type2_Base{"Name"}!~/anon\-/)
14581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
145821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
145838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} and $Type2_Base{"Size"}
145848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} ne $Type2_Base{"Size"})
14585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{$Prefix."_BaseType_And_Size"}}=(
14587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_Base{"Name"},
14588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_Base{"Name"},
14589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14590f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
145948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(diffTypes($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Level))
14595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # format change
14596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType_Format"}}=(
14597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14599f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14600f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(tNameLock($Type1_Base{"Tid"}, $Type2_Base{"Tid"}))
14603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType"}}=(
14605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14607f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14608f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type1{"Name"} ne $Type2{"Name"})
14614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # type change
14615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"}!~/anon\-/ and $Type2{"Name"}!~/anon\-/)
14616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14617f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Prefix eq "Return"
14618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1_Pure{"Name"} eq "void")
14619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_From_Void"}}=(
14621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2{"Name"},
14622f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Prefix eq "Return"
14625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2_Pure{"Name"} eq "void")
14626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_Became_Void"}}=(
14628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1{"Name"},
14629f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE);
14630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
146331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
14634dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} and $Type2{"Size"}
14635dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} ne $Type2{"Size"})
14636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_Type_And_Size"}}=(
14638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1{"Name"},
14639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2{"Name"},
14640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14641f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
14644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
146458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(diffTypes($Type1_Id, $Type2_Id, $Level))
14646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # format change
14647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type_Format"}}=(
14648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14650f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14651f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    elsif(tNameLock($Type1_Id, $Type2_Id))
14654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # FIXME: correct this condition
14655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type"}}=(
14656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14658f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14659f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_PLevel!=$Type2_PLevel)
14666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"} ne "void" and $Type1{"Name"} ne "..."
14668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Type2{"Name"} ne "void" and $Type2{"Name"} ne "...")
14669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
146701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
146711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
146721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$LocalProblems{$Prefix."_PointerLevel"}}=(
14673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_PLevel,
14674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_PLevel);
14675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
146761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
146771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
14678fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Type2_PLevel>$Type1_PLevel)
14679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
146801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Increased"}}=(
146811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
146821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
146831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
14685fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
146861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Decreased"}}=(
146871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
146881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
146891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14693ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    if($Type1_Pure{"Type"} eq "Array"
14694ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    and $Type1_Pure{"BaseType"})
14695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base_type[N] -> base_type[N]
14696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # base_type: older_structure -> typedef to newer_structure
146971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my %SubProblems = detectTypeChange($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Prefix, $Level);
14698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SubProblemType=~s/_Type/_BaseType/g;
14701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(defined $LocalProblems{$SubProblemType});
14702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Attr (keys(%{$SubProblems{$SubProblemType}})) {
14703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $LocalProblems{$SubProblemType}{$Attr} = $SubProblems{$SubProblemType}{$Attr};
14704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %LocalProblems;
14708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub tNameLock($$)
14711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Tid1, $Tid2) = @_;
147130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Changed = 0;
147140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(differentDumps("G"))
147150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different GCC versions
147160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Changed = 1;
147170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
147180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif(differentDumps("V"))
147190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different versions of ABI dumps
1472074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1472174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
147220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # latest names update
147230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.6: added restrict qualifier
147240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.13: added missed typedefs to qualified types
1472574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko          # 2.20: prefix for struct, union and enum types
147260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Changed = 1;
147270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
147280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
147298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN1 = $TypeInfo{1}{$Tid1}{"Name"};
147318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN2 = $TypeInfo{2}{$Tid2}{"Name"};
147328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147332b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT1 = $TypeInfo{1}{$Tid1}{"Type"};
147342b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko    my $TT2 = $TypeInfo{2}{$Tid2}{"Type"};
147352b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
147360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Changed)
14737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
1473862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base1 = get_Type($Tid1, 1);
147390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base1{"Type"} and $Base1{"Type"} eq "Typedef") {
14740f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base1 = get_OneStep_BaseType($Base1{"Tid"}, $TypeInfo{1});
14741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1474262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base2 = get_Type($Tid2, 2);
147430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base2{"Type"} and $Base2{"Type"} eq "Typedef") {
14744f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base2 = get_OneStep_BaseType($Base2{"Tid"}, $TypeInfo{2});
14745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14746850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName1 = uncover_typedefs($Base1{"Name"}, 1);
14747850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName2 = uncover_typedefs($Base2{"Name"}, 2);
14748850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($BName1 eq $BName2)
14749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # equal base types
14750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
147520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1475362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1475462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.13"))
147550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # broken array names in ABI dumps < 2.13
147560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($TT1 eq "Array"
1475774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TT2 eq "Array") {
147580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 0;
147590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
147600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
147610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1476262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.6")
1476362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.6"))
147640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # added restrict attribute in 2.6
1476562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TN1!~/\brestrict\b/
1476674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TN2=~/\brestrict\b/) {
1476774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return 0;
1476874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1476974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1477074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1477174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1477274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
14773d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        { # added type prefix in 2.20
1477474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/
1477574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            or $TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
14776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
14777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
147808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    else
147818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
147828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct {...} type_t
147838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct type_t {...} type_t
147848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN1, " ".$TN2)!=-1)
147858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
147868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/) {
147878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
147888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
147898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
147908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN2, " ".$TN1)!=-1)
147918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
147928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
147938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
147948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
147958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
147962b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
147972b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        if($TT1 eq "FuncPtr"
147982b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        and $TT2 eq "FuncPtr")
147992b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        {
148002b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN1_C = $TN1;
148012b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            my $TN2_C = $TN2;
148022b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
148032b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN1_C=~s/\b(struct|union) //g;
148042b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            $TN2_C=~s/\b(struct|union) //g;
148052b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko
148062b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if($TN1_C eq $TN2_C) {
148072b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                return 0;
148082b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
148092b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
148108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
14811d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
14812d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my ($N1, $N2) = ($TN1, $TN2);
14813d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N1=~s/\b(struct|union) //g;
14814d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    $N2=~s/\b(struct|union) //g;
14815d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
14816d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($N1 eq $N2)
14817d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    { # QList<struct QUrl> and QList<QUrl>
14818d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        return 0;
14819d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
14820d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
14821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
14822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
148241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub differentDumps($)
14825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
148261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Check = $_[0];
14827989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(defined $Cache{"differentDumps"}{$Check}) {
14828989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $Cache{"differentDumps"}{$Check};
14829989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
14830dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UsedDump{1}{"V"} and $UsedDump{2}{"V"})
148311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
14832dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "G")
14833dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
14834dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(getGccVersion(1) ne getGccVersion(2))
14835dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different GCC versions
14836989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
14837dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
148381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
14839dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "V")
14840dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
14841dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(cmpVersions(formatVersion($UsedDump{1}{"V"}, 2),
14842dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            formatVersion($UsedDump{2}{"V"}, 2))!=0)
14843dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different dump versions (skip micro version)
14844989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
14845dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
148461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
14847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14848989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($Cache{"differentDumps"}{$Check}=0);
14849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub formatVersion($$)
14852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # cut off version digits
14853dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($V, $Digits) = @_;
14854dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my @Elems = split(/\./, $V);
14855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(".", splice(@Elems, 0, $Digits));
14856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub htmlSpecChars($)
14859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
148615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
148625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
14863dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
14865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/</&lt;/g;
14866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\-\>/&#45;&gt;/g; # &minus;
14867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/>/&gt;/g;
148688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
148698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
14870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/ /&#160;/g; # &nbsp;
148718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/\@SP\@/ /g;
14872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\n/<br\/>/g;
14873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
14874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
14875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
14876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
148785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub xmlSpecChars($)
148795c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
148805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $Str = $_[0];
148815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
148825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
148835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
148845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
148855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
148865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/</&lt;/g;
148875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/>/&gt;/g;
148885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
148895c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
148905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
148915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
148925c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return $Str;
148935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
148945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
1489501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub xmlSpecChars_R($)
1489601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
1489701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Str = $_[0];
1489801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Str) {
1489901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return $Str;
1490001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1490101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1490201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&amp;/&/g;
1490301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&lt;/</g;
1490401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&gt;/>/g;
1490501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1490601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&quot;/"/g;
1490701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&#39;/'/g;
1490801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1490901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return $Str;
1491001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1491101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
14912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub black_name($)
14913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
14915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<span class='iname_b'>".highLight_Signature($Name)."</span>";
14916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature($)
14919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
14921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 0, 0, 0);
14922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_Italic_Color($)
14925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
14927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 1, 1, 1);
14928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_symbol($)
14931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
14933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Spec, $Ver) = ($Symbol, "", "");
14934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Symbol=~/\A([^\@\$\?]+)([\@\$]+)([^\@\$]+)\Z/) {
14935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($Name, $Spec, $Ver) = ($1, $2, $3);
14936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $Spec, $Ver);
14938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_f_attrs($)
14941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~s/(\))((| (const volatile|const|volatile))(| \[static\]))\Z/$1/) {
14943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
14944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
14946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_PPos_Italic($$$$$)
14949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14950dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($FullSignature, $Param_Pos, $ItalicParams, $ColorParams, $ShowReturn) = @_;
14951dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Param_Pos = "" if(not defined $Param_Pos);
14952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Signature, $VersionSpec, $SymbolVersion) = separate_symbol($FullSignature);
14953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Return = "";
14954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowRetVal and $Signature=~s/([^:]):([^:].+?)\Z/$1/g) {
14955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Return = $2;
14956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
149571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $SCenter = find_center($Signature, "(");
14958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SCenter)
149591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # global data
14960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature = htmlSpecChars($Signature);
149618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature=~s!(\[data\])!<span class='attr'>$1</span>!g;
149621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= (($SymbolVersion)?"<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>":"");
14963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Return and $ShowReturn) {
149641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
14965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Signature;
14967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Begin, $End) = (substr($Signature, 0, $SCenter), "");
14969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Begin.=" " if($Begin!~/ \Z/);
14970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $End = cut_f_attrs($Signature);
14971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
1497207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Short, $Params) = split_Signature($Signature);
1497307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my @SParts = separate_Params($Params, 1, 1);
14974dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $Pos (0 .. $#SParts)
14975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14976dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Part = $SParts[$Pos];
14977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part=~s/\A\s+|\s+\Z//g;
14978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Part_Styled, $ParamName) = (htmlSpecChars($Part), "");
14979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Part=~/\([\*]+(\w+)\)/i) {
14980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;#func-ptr
14981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part=~/(\w+)[\,\)]*\Z/i) {
14983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;
14984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
149858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $ParamName)
149868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
14987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Parts, $Part_Styled);
14988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
14989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ItalicParams and not $TName_Tid{1}{$Part}
14991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $TName_Tid{2}{$Part})
14992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
149930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            my $Style = "param";
14994dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Param_Pos ne ""
14995dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            and $Pos==$Param_Pos) {
149960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "focus_p";
14997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($ColorParams) {
149990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "color_p";
15000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
150010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Part_Styled =~ s!(\W)$ParamName([\,\)]|\Z)!$1<span class=\'$Style\'>$ParamName</span>$2!ig;
15002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part_Styled=~s/,(\w)/, $1/g;
15004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Parts, $Part_Styled);
15005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Parts)
15007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (0 .. $#Parts)
15009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Num==$#Parts)
15011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # add ")" to the last parameter
15012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]." )</span>";
15013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif(length($Parts[$Num])<=45) {
15015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]."</span>";
15016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
150181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;".join(" ", @Parts)."</span>".$End;
15019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
150211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;)</span>".$End;
15022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Return and $ShowReturn) {
150241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
150261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!\[\]![&#160;]!g;
150271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!operator=!operator&#160;=!g;
150288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Signature=~s!(\[in-charge\]|\[not-in-charge\]|\[in-charge-deleting\]|\[static\])!<span class='attr'>$1</span>!g;
150298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($SymbolVersion) {
150308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= "<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>";
150318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
150328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return $Signature;
15033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1503507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub split_Signature($)
15036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1503707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my $Signature = $_[0];
1503807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1503907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
1504007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E\(//g;
1504107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        cut_f_attrs($Signature);
1504207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\)\Z//;
1504307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return ($ShortName, $Signature);
1504407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
1504507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1504607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # error
1504707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    return ($Signature, "");
15048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1505007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub separate_Params($$$)
15051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1505207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Params, $Comma, $Sp) = @_;
15053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
150541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
150551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Part = 0;
15056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Params) - 1)
15057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
150581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $S = substr($Params, $Pos, 1);
150591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $B{$S}) {
1506007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $B{$S} += 1;
150611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
150621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($S eq "," and
150631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $B{"("}==$B{")"} and $B{"<"}==$B{">"})
15064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
150651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Comma)
150661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # include comma
150671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Parts[$Part] .= $S;
15068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
150691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Part += 1;
15070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
150721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Parts[$Part] .= $S;
15073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1507507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(not $Sp)
1507607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    { # remove spaces
1507707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        foreach (@Parts)
1507807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1507907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/\A //g;
1508007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/ \Z//g;
1508107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1508207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
15083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Parts;
15084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub find_center($$)
15087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Sign, $Target) = @_;
150891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
15090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Center = 0;
150911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Sign=~s/(operator([^\w\s\(\)]+|\(\)))//g)
150921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # operators
15093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=length($1);
15094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Sign)-1)
15096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $S = substr($Sign, $Pos, 1);
15098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S eq $Target)
15099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($B{"("}==$B{")"}
15101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $B{"<"}==$B{">"}) {
15102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Center;
15103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $B{$S}) {
15106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $B{$S}+=1;
15107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=1;
15109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
15111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub appendFile($$)
15114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">>", $Path) || die ("can't open file \'$Path\': $!\n");
15121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeFile($$)
15126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n");
15133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readFile($)
15138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
151411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    local $/ = undef;
15143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = <FILE>;
15144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15145850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Path!~/\.(tu|class|abi)\Z/) {
15146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\r/\n/g;
15147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
15149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_filename($)
15152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than basename() from File::Basename module
15153850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_filename"}{$_[0]}) {
15154850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_filename"}{$_[0]};
15155850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
151561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) {
15157850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_filename"}{$_[0]}=$1);
15158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15159850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_filename"}{$_[0]}="");
15160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dirname($)
15163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than dirname() from File::Basename module
15164850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_dirname"}{$_[0]}) {
15165850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_dirname"}{$_[0]};
15166850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
151671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) {
15168850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_dirname"}{$_[0]}=$1);
15169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15170850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_dirname"}{$_[0]}="");
15171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_path($) {
15174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (get_dirname($_[0]), get_filename($_[0]));
15175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub esc($)
15178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
15180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/([()\[\]{}$ &'"`;,<>\+])/\\$1/g;
15181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLineNum($$)
15185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Num) = @_;
15187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
151881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (1 ... $Num) {
15190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        <FILE>;
15191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Line = <FILE>;
15193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Line;
15195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
151970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub readAttributes($$)
15198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
151990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Path, $Num) = @_;
15200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -f $Path);
15201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Attributes = ();
15202850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(readLineNum($Path, $Num)=~/<!--\s+(.+)\s+-->/)
15203850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15204850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $AttrVal (split(/;/, $1))
15205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($AttrVal=~/(.+):(.+)/)
15207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
15209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Attributes{$Name} = $Value;
15210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Attributes;
15214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_abs($) {
15217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($_[0]=~/\A(\/|\w+:[\/\\])/);
15218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_abs_path($)
15221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # abs_path() should NOT be called for absolute inputs
15222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # because it can change them
15223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not is_abs($Path)) {
15225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = abs_path($Path);
15226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
15228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_OSgroup()
15231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15232f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $Config{"osname"};
15233f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($N=~/macos|darwin|rhapsody/i) {
15234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "macos";
15235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15236f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/freebsd|openbsd|netbsd/i) {
15237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "bsd";
15238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15239f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/haiku|beos/i) {
15240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "beos";
15241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15242f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/symbian|epoc/i) {
15243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "symbian";
15244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15245f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/win/i) {
15246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "windows";
15247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
15249f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return $N;
15250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getGccVersion($)
15254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GCC_VERSION{$LibVersion})
15257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $GCC_VERSION{$LibVersion};
15259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccVersion = get_dumpversion($GCC_PATH); # host version
15265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GccVersion) {
15266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccVersion;
15269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showArch($)
15272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = $_[0];
15274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch eq "arm"
15275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Arch eq "mips") {
15276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return uc($Arch);
15277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArch($)
15282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1528454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1528554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if($TargetArch) {
1528654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        return $TargetArch;
1528754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
15288d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    elsif($CPU_ARCH{$LibVersion})
15289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $CPU_ARCH{$LibVersion};
15291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1529654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
15297d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return getArch_GCC($LibVersion);
15298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1530052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenkosub get_Report_Title($)
15301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
153021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
1530352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ArchInfo = " on <span style='color:Blue;'>".showArch(getArch(1))."</span>";
153051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getArch(1) ne getArch(2)
153061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or getArch(1) eq "unknown"
153071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
15308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # don't show architecture in the header
15309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ArchInfo="";
15310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1531152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $Title = "";
153121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Source") {
1531352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Source compatibility";
153141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
153151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Binary") {
1531652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "Binary compatibility";
153171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
153181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
1531952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= "API compatibility";
153201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1532152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1532252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($UsedDump{1}{"DWARF"} and $UsedDump{2}{"DWARF"})
1532352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1532452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M1 = $UsedDump{1}{"M"};
1532552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        my $M2 = $UsedDump{2}{"M"};
1532652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1532752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if($M1 eq $M2)
1532852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1532952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Title .= " report for the <span style='color:Blue;'>$M1</span> object";
1533052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Title .= " between <span style='color:Red;'>".$Descriptor{1}{"Version"}."</span> and <span style='color:Red;'>".$Descriptor{2}{"Version"}."</span> versions";
1533152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1533252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        else
1533352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1533452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Title .= " report between <span style='color:Blue;'>$M1</span> (<span style='color:Red;'>".$Descriptor{1}{"Version"}."</span>)";
1533552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Title .= " and <span style='color:Blue;'>$M2</span> (<span style='color:Red;'>".$Descriptor{2}{"Version"}."</span>) objects";
1533652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
1533752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1533852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    else
1533952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1534014b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $Title .= " report for the <span style='color:Blue;'>$TargetTitle</span> $TargetComponent";
1534152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Title .= " between <span style='color:Red;'>".$Descriptor{1}{"Version"}."</span> and <span style='color:Red;'>".$Descriptor{2}{"Version"}."</span> versions";
1534252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
1534352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1534452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title .= $ArchInfo;
1534552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath) {
1534701e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko        $Title .= " (relating to the portability of application <span style='color:Blue;'>".get_filename($AppPath)."</span>)";
15348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1534952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Title = "<h1>".$Title."</h1>\n";
1535052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    return $Title;
15351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15353ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenkosub get_CheckedHeaders($)
15354ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko{
15355ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my $LibVersion = $_[0];
15356ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15357ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    my @Headers = ();
15358ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15359ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
15360ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
15361ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        my $File = get_filename($Path);
15362ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not is_target_header($File, $LibVersion)) {
15363ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15364ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15365ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15366ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(skipHeader($File, $LibVersion)) {
15367ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            next;
15368ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
15369ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15370ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        push(@Headers, $Path);
15371ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
15372ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15373ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    return @Headers;
15374ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko}
15375ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
15376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SourceInfo()
15377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15378fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($CheckedHeaders, $CheckedSources, $CheckedLibs) = ("", "");
15379ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15380ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Headers = get_CheckedHeaders(1))
15381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15382ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders = "<a name='Headers'></a><h2>Header Files (".($#Headers+1).")</h2><hr/>\n";
15383ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<div class='h_list'>\n";
15384ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
1538562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
15386ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Headers{1}{$Header_Path}{"Identity"};
15387ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15388ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15389ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedHeaders .= $Name.$Comment."<br/>\n";
15390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15391ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "</div>\n";
15392ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedHeaders .= "<br/>$TOP_REF<br/>\n";
15393ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15394ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15395ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(my @Sources = keys(%{$Registered_Sources{1}}))
15396ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15397ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources = "<a name='Sources'></a><h2>Source Files (".($#Sources+1).")</h2><hr/>\n";
15398ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<div class='h_list'>\n";
15399ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Header_Path (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15401ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Identity = $Registered_Sources{1}{$Header_Path}{"Identity"};
15402ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Name = get_filename($Identity);
15403ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15404ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckedSources .= $Name.$Comment."<br/>\n";
1540562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
15406ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "</div>\n";
15407ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $CheckedSources .= "<br/>$TOP_REF<br/>\n";
15408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15409ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
1541062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckHeadersOnly)
15411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15412fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $CheckedLibs = "<a name='Libs'></a><h2>".get_ObjTitle()." (".keys(%{$Library_Symbol{1}}).")</h2><hr/>\n";
1541362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<div class='lib_list'>\n";
1541462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
1541562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1541662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
1541762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $CheckedLibs .= $Library."<br/>\n";
1541862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1541962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "</div>\n";
1542062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<br/>$TOP_REF<br/>\n";
15421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15422ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
15423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $CheckedHeaders.$CheckedSources.$CheckedLibs;
15424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
15425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub get_ObjTitle()
15427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
15428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"}) {
15429fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return "Objects";
15430fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else {
15432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return ucfirst($SLIB_TYPE)." Libraries";
15433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TypeProblems_Count($$$)
15437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeChanges, $TargetPriority, $Level) = @_;
15439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Type_Problems_Count = 0;
15440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (sort keys(%{$TypeChanges}))
15441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
15443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges->{$Type_Name}}))
15444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges->{$Type_Name}{$Kind}}))
15446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges->{$Type_Name}{$Kind}{$Location}{"Target"};
154482489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
154492489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next if($Severity ne $TargetPriority);
15450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Kinds_Target{$Kind}{$Target}) {
15451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
154532489ef88760861175102e4508089608391beead3Andrey Ponomarenko
154542489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target})
154552489ef88760861175102e4508089608391beead3Andrey Ponomarenko                {
154562489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
154572489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    { # select a problem with the highest priority
154582489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        next;
154592489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    }
15460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
15462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Type_Problems_Count += 1;
15463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Type_Problems_Count;
15467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Summary($)
15470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
154711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
154721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Added, $Removed, $I_Problems_High, $I_Problems_Medium, $I_Problems_Low, $T_Problems_High,
154738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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);
154741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %{$RESULT{$Level}} = (
154751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Problems"=>0,
154761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Warnings"=>0,
154771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Affected"=>0 );
15478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check rules
154791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
154811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
15484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unknown rule
15485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
15486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # only one warning
15487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
15488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
15489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
154901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                delete($CompatProblems{$Level}{$Interface}{$Kind});
15491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
154948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (sort keys(%{$CompatProblems_Constants{$Level}}))
154958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
154968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
154978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
154988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
154998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # unknown rule
155008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
155018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # only one warning
155028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
155038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
155048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
155058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($CompatProblems_Constants{$Level}{$Constant}{$Kind});
155068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
155078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
155088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
155091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
155111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
15512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols")
15514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
155151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
155172489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
155181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Kind eq "Added_Symbol") {
15519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added += 1;
15520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
155211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($Kind eq "Removed_Symbol")
15522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed += 1;
155242489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = $Severity;
15525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
15527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
155282489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity eq "Safe") {
15529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Other += 1;
15530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
155312489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "High") {
15532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_High += 1;
15533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
155342489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Medium") {
15535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Medium += 1;
15536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
155372489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Low") {
15538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Low += 1;
15539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
155402489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if(($Severity ne "Low" or $StrictCompat)
155412489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        and $Severity ne "Safe") {
155422489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeChanges = ();
155501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
155521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
15555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15556f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
155581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Type_Name = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
155591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
155602489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
15561f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target};
15562f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
155632489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($MaxSeverity and $Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
15564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # select a problem with the highest priority
15565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
15566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15567f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
155682489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(($Severity ne "Low" or $StrictCompat)
155692489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    and $Severity ne "Safe")
15570f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
15571f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if(defined $TotalAffected{$Level}{$Interface})
15572f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
155732489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            if($Severity_Val{$Severity}>$Severity_Val{$TotalAffected{$Level}{$Interface}}) {
155742489ef88760861175102e4508089608391beead3Andrey Ponomarenko                                $TotalAffected{$Level}{$Interface} = $Severity;
15575f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            }
15576f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15577f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        else {
155782489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15579f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15580f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15581f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15582f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeChanges{$Type_Name}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
15583f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15584f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($MaxSeverity)
15585f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
155862489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$Severity}>$Severity_Val{$MaxSeverity}) {
155872489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15588f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15589f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15590f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    else {
155912489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
155971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_High = get_TypeProblems_Count(\%TypeChanges, "High", $Level);
15599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Medium = get_TypeProblems_Count(\%TypeChanges, "Medium", $Level);
15600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Low = get_TypeProblems_Count(\%TypeChanges, "Low", $Level);
15601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Other = get_TypeProblems_Count(\%TypeChanges, "Safe", $Level);
156021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15603f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    %TypeChanges = (); # free memory
15604f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15605ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # changed and removed public symbols
15606ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    my $SCount = keys(%{$CheckedSymbols{$Level}});
15607ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($ExtendedCheck)
15608ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # don't count external_func_0 for constants
15609ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $SCount-=1;
15610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15611ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($SCount)
15612ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
15613ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my %Weight = (
15614ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "High" => 100,
15615ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Medium" => 50,
15616ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            "Low" => 25
15617ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        );
15618ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach (keys(%{$TotalAffected{$Level}})) {
15619ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $RESULT{$Level}{"Affected"}+=$Weight{$TotalAffected{$Level}{$_}};
15620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15621ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = $RESULT{$Level}{"Affected"}/$SCount;
15622ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
15623ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
15624ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 0;
15625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15626ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
156271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Affected"} = show_number($RESULT{$Level}{"Affected"});
156281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($RESULT{$Level}{"Affected"}>=100) {
156291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 100;
15630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $Removed;
15633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_High + $I_Problems_High;
156341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_Medium + $I_Problems_Medium;
15635850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($StrictCompat) {
15636850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Problems"} += $T_Problems_Low + $I_Problems_Low;
15637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Warnings"} += $T_Problems_Low + $I_Problems_Low;
15640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
156428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
156431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
156448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
15645850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15646f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
156478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Severity eq "Safe")
156488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
156498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Other+=1;
15650850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
156518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            elsif($Severity eq "Low")
156528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
156538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Problems_Low+=1;
15654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
156551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
156568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
156578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
156588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($C_Problems_Low)
156598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
156608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($StrictCompat) {
156618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += $C_Problems_Low;
156628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
156638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else {
156648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += $C_Problems_Low;
156651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
156661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
15667850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($RESULT{$Level}{"Problems"}
15668850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    and $RESULT{$Level}{"Affected"}) {
15669850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "incompatible";
15670850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15671850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15672850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "compatible";
156731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
156741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
156751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $TotalTypes = keys(%{$CheckedTypes{$Level}});
156761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $TotalTypes)
156771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # list all the types
15678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TotalTypes = keys(%{$TName_Tid{1}});
15679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Arch1, $Arch2) = (getArch(1), getArch(2));
15682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($GccV1, $GccV2) = (getGccVersion(1), getGccVersion(2));
15683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TestInfo, $TestResults, $Problem_Summary) = ();
15685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
15687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
15688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <library>$TargetLibraryName</library>\n";
15690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version1>\n";
15691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{1}{"Version"}."</number>\n";
15692d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch1</arch>\n";
15693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV1</gcc>\n";
15694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version1>\n";
15695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version2>\n";
15697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{2}{"Version"}."</number>\n";
15698d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $TestInfo .= "    <arch>$Arch2</arch>\n";
15699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV2</gcc>\n";
15700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version2>\n";
15701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<test_info>\n".$TestInfo."</test_info>\n\n";
15702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15704fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15706fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <headers>\n";
15707fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15708fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15709fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Name}{"Identity"};
15710fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15711fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15712fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15713fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </headers>\n";
15714fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15716fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15717fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15718fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <sources>\n";
15719fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15720fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15721fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Name}{"Identity"};
15722fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15723fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15724fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15725fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </sources>\n";
15726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <libs>\n";
15729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
15730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
15732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestResults .= "    <name>$Library</name>\n";
15733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  </libs>\n";
15735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1573662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "  <symbols>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))."</symbols>\n";
15737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <types>".$TotalTypes."</types>\n";
15738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
157391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <verdict>".$RESULT{$Level}{"Verdict"}."</verdict>\n";
157401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <affected>".$RESULT{$Level}{"Affected"}."</affected>\n";
15741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<test_results>\n".$TestResults."</test_results>\n\n";
15742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <added_symbols>".$Added."</added_symbols>\n";
15745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <removed_symbols>".$Removed."</removed_symbols>\n";
15746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_types>\n";
15748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$T_Problems_High</high>\n";
15749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$T_Problems_Medium</medium>\n";
15750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$T_Problems_Low</low>\n";
15751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <safe>$T_Other</safe>\n";
15752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_types>\n";
15753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_symbols>\n";
15755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$I_Problems_High</high>\n";
15756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$I_Problems_Medium</medium>\n";
15757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$I_Problems_Low</low>\n";
157581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <safe>$I_Other</safe>\n";
15759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_symbols>\n";
15760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_constants>\n";
157621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <low>$C_Problems_Low</low>\n";
15763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_constants>\n";
1576452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
15765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<problem_summary>\n".$Problem_Summary."</problem_summary>\n\n";
15766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, "");
15768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
15770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
15771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<h2>Test Info</h2><hr/>\n";
157731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestInfo .= "<table class='summary'>\n";
1577414b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $TestInfo .= "<tr><th>".ucfirst($TargetComponent)." Name</th><td>$TargetTitle</td></tr>\n";
15775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@VInf1, @VInf2, $AddTestInfo) = ();
15777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch1 ne "unknown"
15778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Arch2 ne "unknown")
15779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # CPU arch
15780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Arch1 eq $Arch2)
15781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
157821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $AddTestInfo .= "<tr><th>CPU Type</th><td>".showArch($Arch1)."</td></tr>\n";
15783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, showArch($Arch1));
15787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, showArch($Arch2));
15788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GccV1 ne "unknown"
15791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $GccV2 ne "unknown"
15792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $OStarget ne "windows")
15793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # GCC version
15794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GccV1 eq $GccV2)
15795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
15796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AddTestInfo .= "<tr><th>GCC Version</th><td>$GccV1</td></tr>\n";
15797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, "gcc ".$GccV1);
15801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, "gcc ".$GccV2);
15802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # show long version names with GCC version and CPU architecture name (if different)
15805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #1</th><td>".$Descriptor{1}{"Version"}.(@VInf1?" (".join(", ", reverse(@VInf1)).")":"")."</td></tr>\n";
15806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #2</th><td>".$Descriptor{2}{"Version"}.(@VInf2?" (".join(", ", reverse(@VInf2)).")":"")."</td></tr>\n";
15807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= $AddTestInfo;
15808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($COMMON_LANGUAGE{1}) {
15809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #    $TestInfo .= "<tr><th>Language</th><td>".$COMMON_LANGUAGE{1}."</td></tr>\n";
15810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
15811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck) {
15812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestInfo .= "<tr><th>Mode</th><td>Extended</td></tr>\n";
15813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
158141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
158151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
158161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary") {
158171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>\n"; # Run-time
158181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source") {
158201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>\n"; # Build-time
158211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "</table>\n";
15824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<h2>Test Results</h2><hr/>\n";
158271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "<table class='summary'>";
15828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158296ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        if(my @Headers = get_CheckedHeaders(1))
15830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Headers_Link = "<a href='#Headers' style='color:Blue;'>".($#Headers + 1)."</a>";
15832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>".$Headers_Link."</td></tr>\n";
15833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15834fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15837fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Src_Link = "<a href='#Sources' style='color:Blue;'>".($#Sources + 1)."</a>";
15838fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Source Files</th><td>".$Src_Link."</td></tr>\n";
15839fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck)
15842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Libs_Link = "0";
15844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Libs_Link = "<a href='#Libs' style='color:Blue;'>".keys(%{$Library_Symbol{1}})."</a>" if(keys(%{$Library_Symbol{1}})>0);
15845fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total ".get_ObjTitle()."</th><td>".($CheckHeadersOnly?"0&#160;(not&#160;analyzed)":$Libs_Link)."</td></tr>\n";
15846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1584862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "<tr><th>Total Symbols / Types</th><td>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))." / ".$TotalTypes."</td></tr>\n";
15849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $META_DATA = "verdict:".$RESULT{$Level}{"Verdict"}.";";
158511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport) {
158521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $META_DATA = "kind:".lc($Level).";".$META_DATA;
158531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
158541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "<tr><th>Verdict</th>";
15855850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($RESULT{$Level}{"Verdict"} eq "incompatible") {
158561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Red;'><b>Incompatible<br/>(".$RESULT{$Level}{"Affected"}."%)</b></span></td>";
158571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
158581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else {
158591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Green;'><b>Compatible</b></span></td>";
158601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
158611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "</tr>\n";
15862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "</table>\n";
15863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "affected:".$RESULT{$Level}{"Affected"}.";";# in percents
15865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<h2>Problem Summary</h2><hr/>\n";
158671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "<table class='summary'>";
15868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "<tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr>";
15869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Link = "0";
158711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Added>0)
158721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
158731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
158741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#".$Level."_Added' style='color:Blue;'>$Added</a>";
158751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
158771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#Added' style='color:Blue;'>$Added</a>";
158781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "added:$Added;";
158811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Added Symbols</th><td>-</td><td".getStyle("I", "A", $Added).">$Added_Link</td></tr>\n";
15882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Removed_Link = "0";
158841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Removed>0)
158851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
158861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
158871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#".$Level."_Removed' style='color:Blue;'>$Removed</a>"
158881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
158901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#Removed' style='color:Blue;'>$Removed</a>"
158911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
158921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "removed:$Removed;";
158941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Removed Symbols</th>";
158951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "R", $Removed).">$Removed_Link</td></tr>\n";
15896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TH_Link = "0";
158981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TH_Link = "<a href='#".get_Anchor("Type", $Level, "High")."' style='color:Blue;'>$T_Problems_High</a>" if($T_Problems_High>0);
15899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_high:$T_Problems_High;";
159001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Data Types</th>";
159011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("T", "H", $T_Problems_High).">$TH_Link</td></tr>\n";
15902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TM_Link = "0";
159041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TM_Link = "<a href='#".get_Anchor("Type", $Level, "Medium")."' style='color:Blue;'>$T_Problems_Medium</a>" if($T_Problems_Medium>0);
15905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_medium:$T_Problems_Medium;";
159061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("T", "M", $T_Problems_Medium).">$TM_Link</td></tr>\n";
15907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TL_Link = "0";
159091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TL_Link = "<a href='#".get_Anchor("Type", $Level, "Low")."' style='color:Blue;'>$T_Problems_Low</a>" if($T_Problems_Low>0);
15910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_low:$T_Problems_Low;";
159111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("T", "L", $T_Problems_Low).">$TL_Link</td></tr>\n";
15912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IH_Link = "0";
159141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IH_Link = "<a href='#".get_Anchor("Symbol", $Level, "High")."' style='color:Blue;'>$I_Problems_High</a>" if($I_Problems_High>0);
15915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_high:$I_Problems_High;";
159161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Symbols</th>";
159171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "H", $I_Problems_High).">$IH_Link</td></tr>\n";
15918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IM_Link = "0";
159201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IM_Link = "<a href='#".get_Anchor("Symbol", $Level, "Medium")."' style='color:Blue;'>$I_Problems_Medium</a>" if($I_Problems_Medium>0);
15921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_medium:$I_Problems_Medium;";
159221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("I", "M", $I_Problems_Medium).">$IM_Link</td></tr>\n";
15923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IL_Link = "0";
159251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IL_Link = "<a href='#".get_Anchor("Symbol", $Level, "Low")."' style='color:Blue;'>$I_Problems_Low</a>" if($I_Problems_Low>0);
15926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_low:$I_Problems_Low;";
159271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("I", "L", $I_Problems_Low).">$IL_Link</td></tr>\n";
15928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ChangedConstants_Link = "0";
159308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}}) and $C_Problems_Low) {
159318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedConstants_Link = "<a href='#".get_Anchor("Constant", $Level, "Low")."' style='color:Blue;'>$C_Problems_Low</a>";
15932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
159331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "changed_constants:$C_Problems_Low;";
159341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
15935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Safe Changes
15937ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($T_Other)
159381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
159391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $TS_Link = "<a href='#".get_Anchor("Type", $Level, "Safe")."' style='color:Blue;'>$T_Other</a>";
159401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
159411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
159421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15943ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($I_Other)
159441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
159451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $IS_Link = "<a href='#".get_Anchor("Symbol", $Level, "Safe")."' style='color:Blue;'>$I_Other</a>";
159461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Symbols</th><td>-</td><td".getStyle("I", "S", $I_Other).">$IS_Link</td></tr>\n";
15947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15949ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($C_Other)
159508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
159518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $CS_Link = "<a href='#".get_Anchor("Constant", $Level, "Safe")."' style='color:Blue;'>$C_Other</a>";
159528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Constants</th><td>-</td><td".getStyle("C", "S", $C_Other).">$CS_Link</td></tr>\n";
159538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
159548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
15955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "tool_version:$TOOL_VERSION";
15956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "</table>\n";
159571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # $TestInfo = getLegend().$TestInfo;
15958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, $META_DATA);
15959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getStyle($$$)
159631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
159641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Subj, $Act, $Num) = @_;
159651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Style = (
159661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "A"=>"new",
159671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "R"=>"failed",
159681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "S"=>"passed",
159691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "L"=>"warning",
159701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "M"=>"failed",
159711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "H"=>"failed"
159721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
159731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Num>0) {
159741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return " class='".$Style{$Act}."'";
159751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
159761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "";
159771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
159781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
15979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub show_number($)
15980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
159811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($_[0])
15982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
159831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Num = cut_off_number($_[0], 2, 0);
159841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Num eq "0")
159851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
159861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $P (3 .. 7)
159871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
159881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Num = cut_off_number($_[0], $P, 1);
159891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($Num ne "0") {
159901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    last;
159911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
159921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
15993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num eq "0") {
15995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Num = $_[0];
15996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Num;
15998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0];
16000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub cut_off_number($$$)
16003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
160041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($num, $digs_to_cut, $z) = @_;
16005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($num!~/\./)
16006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $num .= ".";
16008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut-1) {
16009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\.(.+)\Z/ and length($1)<$digs_to_cut-1)
16013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut - 1 - length($1)) {
16015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\d+\.(\d){$digs_to_cut,}/) {
16019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      $num=sprintf("%.".($digs_to_cut-1)."f", $num);
16020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $num=~s/\.[0]+\Z//g;
160221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($z) {
160231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $num=~s/(\.[1-9]+)[0]+\Z/$1/g;
160241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $num;
16026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub get_Report_ChangedConstants($$)
16029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
160308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
160311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_CONSTANTS = "";
160328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
160331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
160348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
160358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
160368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Header = $Constants{1}{$Constant}{"Header"};
160378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Header)
160388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # added
160398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Header = $Constants{2}{$Constant}{"Header"}
160408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
160418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
160428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
160438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
160448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind}) {
160458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
160468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
16047f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($TargetSeverity ne $CompatRules{$Level}{$Kind}{"Severity"}) {
160488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
160498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
160508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ReportMap{$Header}{$Constant}{$Kind} = 1;
160518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
160521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
160538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
160561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "  <header name=\"$HeaderName\">\n";
160591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    <constant name=\"$Constant\">\n";
160628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
160638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
160648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = $CompatRules{$Level}{$Kind}{"Change"};
160658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
160668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
160688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      <problem id=\"$Kind\">\n";
160698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <change".getXmlParams($Change, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Change</change>\n";
160708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <effect".getXmlParams($Effect, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Effect</effect>\n";
16071d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    if($Overcome) {
16072d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        $CHANGED_CONSTANTS .= "        <overcome".getXmlParams($Overcome, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Overcome</overcome>\n";
16073d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                    }
160748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      </problem>\n";
160758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
16076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    </constant>\n";
16077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "    </header>\n";
16079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CHANGED_CONSTANTS = "<problems_with_constants severity=\"Low\">\n".$CHANGED_CONSTANTS."</problems_with_constants>\n\n";
16081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Number = 0;
160851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<span class='h_name'>$HeaderName</span><br/>\n";
160888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
160908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $Report = "";
160918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
160928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
160938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
160948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, $CompatProblems_Constants{$Level}{$Constant}{$Kind});
160958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
160968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report .= "<tr><th>1</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>$Effect</td></tr>\n";
160978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Number += 1;
160988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
160998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Report)
161008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
161018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = $ContentDivStart."<table class='ptable'><tr><th width='2%'></th><th width='47%'>Change</th><th>Effect</th></tr>".$Report."</table><br/>$ContentDivEnd\n";
161028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = $ContentSpanStart."<span class='extendable'>[+]</span> ".$Constant.$ContentSpanEnd."<br/>\n".$Report;
161038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = insertIDs($Report);
161048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
161058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $CHANGED_CONSTANTS .= $Report;
16106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<br/>\n";
16108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
161091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CHANGED_CONSTANTS)
161101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Title = "Problems with Constants, $TargetSeverity Severity";
161128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity eq "Safe")
161138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # Safe Changes
161148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Title = "Other Changes in Constants";
161151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
161168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CHANGED_CONSTANTS = "<a name='".get_Anchor("Constant", $Level, $TargetSeverity)."'></a><h2>$Title ($Number)</h2><hr/>\n".$CHANGED_CONSTANTS.$TOP_REF."<br/>\n";
16117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_CONSTANTS;
16120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getTitle($$$)
161231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
161241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Header, $Library, $NameSpace) = @_;
161251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Title = "";
161261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Library and $Library!~/\.\w+\Z/) {
161271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Library .= " (.$LIB_EXT)";
161281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Header and $Library)
161301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
161311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span>";
161321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= ", <span class='lib_name'>$Library</span><br/>\n";
161331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Library) {
161351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='lib_name'>$Library</span><br/>\n";
161361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Header) {
161381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span><br/>\n";
161391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($NameSpace) {
1614174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Title .= "<span class='ns'>namespace <b>$NameSpace</b></span><br/>\n";
161421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
161431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return $Title;
161441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
161451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Added($)
16147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
161481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
161491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ADDED_INTERFACES = "";
161501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
161511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
161531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
16154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
161551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Added_Symbol")
16156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $HeaderName = $CompleteSignature{2}{$Interface}{"Header"};
16158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $DyLib = $Symbol_Library{2}{$Interface};
161591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
161601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
161611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
161621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
161631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
161691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
161721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    <library name=\"$DyLib\">\n";
161751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ADDED_INTERFACES .= "      <name>$Interface</name>\n";
16177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    </library>\n";
16179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  </header>\n";
16181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ADDED_INTERFACES = "<added_symbols>\n".$ADDED_INTERFACES."</added_symbols>\n\n";
16183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Number = 0;
161871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
161891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
161911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
161921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1619374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
161951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
161971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
161981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 2)) cmp lc(get_Signature($b, 2))} keys(%{$NameSpaceSymbols{$NameSpace}});
16199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Interface (@SortedInterfaces)
16200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added_Number += 1;
16202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Signature = get_Signature($Interface, 2);
16203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1620462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
162069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Interface=~/\A(_Z|\?)/)
162079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
162091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= insertIDs($ContentSpanStart.highLight_Signature_Italic_Color($Signature).$ContentSpanEnd."<br/>\n".$ContentDivStart."<span class='mangled'>[symbol: <b>$Interface</b>]</span><br/><br/>".$ContentDivEnd."\n");
16210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
162121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
162159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        else
162169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
162181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
162211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
162251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= "<br/>\n";
16226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
162291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ADDED_INTERFACES)
162301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
162311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Added'></a>";
162321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
162331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Added'></a>";
162341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
162351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ADDED_INTERFACES = $Anchor."<h2>Added Symbols ($Added_Number)</h2><hr/>\n".$ADDED_INTERFACES.$TOP_REF."<br/>\n";
16236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ADDED_INTERFACES;
16239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Removed($)
16242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
162441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $REMOVED_INTERFACES = "";
162451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
16246850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16248850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
162501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Removed_Symbol")
16251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16252850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
162541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
162551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
162561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
162571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
16258850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
162641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
162671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    <library name=\"$DyLib\">\n";
16270850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $REMOVED_INTERFACES .= "      <name>$Symbol</name>\n";
16272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    </library>\n";
16274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  </header>\n";
16276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $REMOVED_INTERFACES = "<removed_symbols>\n".$REMOVED_INTERFACES."</removed_symbols>\n\n";
16278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
162811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Removed_Number = 0;
162821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
162831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
162841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
162851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
162861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
162871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1628874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 1)}{$Interface} = 1;
16289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
162901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
162921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $REMOVED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
162931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16294850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed_Number += 1;
16297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $SubReport = "";
16298850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
16299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1630062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16302850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if($Symbol=~/\A(_Z|\?)/)
163031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
16305850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= insertIDs($ContentSpanStart.highLight_Signature_Italic_Color($Signature).$ContentSpanEnd."<br/>\n".$ContentDivStart."<span class='mangled'>[symbol: <b>$Symbol</b>]</span><br/><br/>".$ContentDivEnd."\n");
16306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16308850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
163111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
163121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
163141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16317850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "<br/>\n";
16323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
163251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($REMOVED_INTERFACES)
163261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
163271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Removed'></a><a name='Withdrawn'></a>";
163281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
163291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Removed'></a><a name='".$Level."_Withdrawn'></a>";
163301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
163311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $REMOVED_INTERFACES = $Anchor."<h2>Removed Symbols ($Removed_Number)</h2><hr/>\n".$REMOVED_INTERFACES.$TOP_REF."<br/>\n";
16332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $REMOVED_INTERFACES;
16335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getXmlParams($$)
16338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Problem) = @_;
16340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %XMLparams = ();
16342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Content=~/\Q$Macro\E/) {
16346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $XMLparams{lc($Attr)} = $Problem->{$Attr};
16347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @PString = ();
16350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $P (sort {$b cmp $a} keys(%XMLparams)) {
163515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        push(@PString, $P."=\"".xmlSpecChars($XMLparams{$P})."\"");
16352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@PString) {
16354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return " ".join(" ", @PString);
16355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
16358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMarkup($)
16362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = $_[0];
16364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # auto-markup
16365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\n[ ]*//; # spaces
16366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(\@\w+\s*\(\@\w+\))!<nowrap>$1</nowrap>!g; # @old_type (@old_size)
16367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(... \(\w+\))!<nowrap><b>$1</b></nowrap>!g; # ... (va_list)
163680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!<nowrap>(.+?)</nowrap>!<span class='nowrap'>$1</span>!g;
16369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!([2-9]\))!<br/>$1!g; # 1), 2), ...
16370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/\ANOTE:/)
16371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # notes
16372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<b>$1</b>:!g;
16373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<br/><b>$1</b>:!g;
16376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s! (out)-! <b>$1</b>-!g; # out-parameters
16378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Keywords = (
16379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "void",
16380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "const",
16381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "static",
16382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "restrict",
16383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "volatile",
16384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "register",
163850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        "virtual"
16386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
16387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MKeys = join("|", @Keywords);
16388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Keywords) {
16389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MKeys .= "|non-".$_;
16390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(added\s*|to\s*|from\s*|became\s*)($MKeys)([^\w-]|\Z)!$1<b>$2</b>$3!ig; # intrinsic types, modifiers
163920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
163930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # Markdown
163940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*\*([\w\-]+)\*\*!<b>$1</b>!ig;
163950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*([\w\-]+)\*!<i>$1</i>!ig;
16396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub applyMacroses($$$$)
16400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind, $Content, $Problem) = @_;
16402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Problem->{"Word_Size"} = $WORD_SIZE{2};
16404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content = addMarkup($Content);
16405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # macros
16406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Value = $Problem->{$Attr};
16410dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(not defined $Value
16411dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        or $Value eq "") {
16412dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            next;
16413dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
1641428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1641528874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if(index($Content, $Macro)==-1) {
1641628874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            next;
1641728874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        }
1641828874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko
1641928874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        if($Kind!~/\A(Changed|Added|Removed)_Constant\Z/
1642028874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Kind!~/_Type_/
1642128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko        and $Value=~/\s\(/ and $Value!~/['"]/)
16422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # functions
164231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s*\[[\w\-]+\]//g; # remove quals
1642428874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko            $Value=~s/\s[a-z]\w*(\)|,)/$1/ig; # remove parameter names
16425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = black_name($Value);
16426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\s/) {
16428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<span class='value'>".htmlSpecChars($Value)."</span>";
16429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\A\d+\Z/
16431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and ($Attr eq "Old_Size" or $Attr eq "New_Size"))
16432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # bits to bytes
16433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Value % $BYTE_SIZE)
16434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bits
16435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bit";
16437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bits";
16440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bytes
16444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value /= $BYTE_SIZE;
16445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> byte";
16447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bytes";
16450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
164530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else
164540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
16455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<b>".htmlSpecChars($Value)."</b>";
16456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\Q$Macro\E/$Value/g;
16458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/(\A|[^\@\w])\@\w/)
16461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $IncompleteRules{$Level}{$Kind})
16463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only one warning
16464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "incomplete rule \"$Kind\" (\"$Level\")");
16465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $IncompleteRules{$Level}{$Kind} = 1;
16466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16471dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub get_Report_SymbolProblems($$)
16472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
164731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
164741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $INTERFACE_PROBLEMS = "";
164751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my (%ReportMap, %SymbolChanges) = ();
164762489ef88760861175102e4508089608391beead3Andrey Ponomarenko
164771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
164791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
164801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
164811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
164821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
164831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols"
164861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Kind ne "Added_Symbol" and $Kind ne "Removed_Symbol")
16487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
164881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
164891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
164901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $DyLib and my $VSym = $SymVer{1}{$Symbol})
16491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Symbol with Version
16492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DyLib = $Symbol_Library{1}{$VSym};
16493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1649462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $DyLib)
1649562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # const global data
1649662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $DyLib = "";
1649762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
164981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
164991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
165001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
165011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
165021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$SymbolChanges{$Symbol}{$Kind}} = %{$CompatProblems{$Level}{$Symbol}{$Kind}};
165031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
165052489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
165062489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity ne $TargetSeverity) {
165071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        delete($SymbolChanges{$Symbol}{$Kind}{$Location});
16508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not keys(%{$SymbolChanges{$Symbol}{$Kind}}))
165111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
165121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    delete($SymbolChanges{$Symbol}{$Kind});
165131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    next;
16514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$SymbolChanges{$Symbol}})) {
165191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolChanges{$Symbol});
165201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
165222489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
165251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
165281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    <library name=\"$DyLib\">\n";
16531d59580888a06555261f3d4255d9c2cfcb408a51aAndrey 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}});
16532d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
16533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      <symbol name=\"$Symbol\">\n";
16535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (keys(%{$SymbolChanges{$Symbol}}))
16536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
165400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16541f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        <problem id=\"$Kind\">\n";
16543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16547d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16548d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                                $INTERFACE_PROBLEMS .= "          <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16549d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            }
16550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        </problem>\n";
16551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      </symbol>\n";
16554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    </library>\n";
16556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  </header>\n";
16558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $INTERFACE_PROBLEMS = "<problems_with_symbols severity=\"$TargetSeverity\">\n".$INTERFACE_PROBLEMS."</problems_with_symbols>\n\n";
16560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
165641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
165661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
165681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my (%NameSpaceSymbols, %NewSignature) = ();
165691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1657074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
16571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
165741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= getTitle($HeaderName, $DyLib, $NameSpace);
1657528874769f026cec2a4c1ac1dfc975eda75275734Andrey 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}});
165761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
165781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
165791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $SYMBOL_REPORT = "";
16580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemNum = 1;
1658128874769f026cec2a4c1ac1dfc975eda75275734Andrey Ponomarenko                        foreach my $Kind (sort keys(%{$SymbolChanges{$Symbol}}))
16582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
165831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
165851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
165860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if($Problem{"New_Signature"}) {
165881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $NewSignature{$Symbol} = $Problem{"New_Signature"};
16589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                {
16592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
165931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $SYMBOL_REPORT .= "<tr><th>$ProblemNum</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>".$Effect."</td></tr>\n";
16594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemNum += 1;
16595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemsNum += 1;
16596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemNum -= 1;
166001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($SYMBOL_REPORT)
16601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
166021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ";
16603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
166041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= highLight_Signature_Italic_Color($Signature);
16605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
166071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= $Symbol;
16608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
166091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= " ($ProblemNum)".$ContentSpanEnd."<br/>\n";
166101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivStart."\n";
166111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($NewSignature{$Symbol})
166121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # argument list changed to
166131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "\n<span class='new_sign_lbl'>changed to:</span><br/><span class='new_sign'>".highLight_Signature_Italic_Color($NewSignature{$Symbol})."</span><br/>\n";
16614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
166151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Symbol=~/\A(_Z|\?)/) {
166161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "<span class='mangled'>&#160;&#160;&#160;&#160;[symbol: <b>$Symbol</b>]</span><br/>\n";
166171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
166181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "<table class='ptable'><tr><th width='2%'></th><th width='47%'>Change</th><th>Effect</th></tr>$SYMBOL_REPORT</table><br/>\n";
166191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivEnd;
16620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($NameSpace) {
1662162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                $INTERFACE_PROBLEMS=~s/\b\Q$NameSpace\E::\b//g;
16622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
166251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "<br/>";
16626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
166292489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($INTERFACE_PROBLEMS)
16631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
166321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $INTERFACE_PROBLEMS = insertIDs($INTERFACE_PROBLEMS);
166331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Symbols, $TargetSeverity Severity";
166341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Symbols";
16637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
166380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey 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";
16639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $INTERFACE_PROBLEMS;
16642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_TypeProblems($$)
16645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
166461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
166471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $TYPE_PROBLEMS = "";
1664874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my (%ReportMap, %TypeChanges) = ();
166492489ef88760861175102e4508089608391beead3Andrey Ponomarenko
166501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
166521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
16653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
16655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16656f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
16657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
166581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $TypeName = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
166591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
16660f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
166612489ef88760861175102e4508089608391beead3Andrey Ponomarenko
166621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Severity eq "Safe"
166631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $TargetSeverity ne "Safe") {
16664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
16665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
166661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
166672489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$TypeName}{$Kind}{$Target})
166682489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    {
166692489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
166702489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        { # select a problem with the highest priority
166712489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            next;
166722489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        }
16673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
166742489ef88760861175102e4508089608391beead3Andrey Ponomarenko
166752489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $TypeChanges{$TypeName}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
16676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
166802489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Kinds_Locations = ();
16682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $TypeName (keys(%TypeChanges))
16683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
166842489ef88760861175102e4508089608391beead3Andrey Ponomarenko        my %Kind_Target = ();
16685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (sort keys(%{$TypeChanges{$TypeName}}))
16686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16687f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16689f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
166901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Severity ne $TargetSeverity)
16691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # other priority
16692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Locations{$TypeName}{$Kind}{$Location} = 1;
16696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges{$TypeName}{$Kind}{$Location}{"Target"};
166972489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Kind_Target{$Kind}{$Target})
16698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicate target
16699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167022489ef88760861175102e4508089608391beead3Andrey Ponomarenko                $Kind_Target{$Kind}{$Target} = 1;
1670362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $HeaderName = $TypeInfo{1}{$TName_Tid{1}{$TypeName}}{"Header"};
167041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$TypeName} = 1;
16705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not keys(%{$TypeChanges{$TypeName}{$Kind}})) {
16707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($TypeChanges{$TypeName}{$Kind});
16708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$TypeChanges{$TypeName}})) {
167111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($TypeChanges{$TypeName});
167121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
167142489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16715850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$CompatProblems{$Level}});
16716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
167181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
167211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}}))
16722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
167235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                $TYPE_PROBLEMS .= "    <type name=\"".xmlSpecChars($TypeName)."\">\n";
16724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16726f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      <problem id=\"$Kind\">\n";
16730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16734d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        if(my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"}) {
16735d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                            $TYPE_PROBLEMS .= "        <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16736d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                        }
16737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      </problem>\n";
16738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16740850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $TYPE_PROBLEMS .= getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
167411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TYPE_PROBLEMS .= showVTables($TypeName);
16743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TYPE_PROBLEMS .= "    </type>\n";
16745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  </header>\n";
16747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TYPE_PROBLEMS = "<problems_with_types severity=\"$TargetSeverity\">\n".$TYPE_PROBLEMS."</problems_with_types>\n\n";
16749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
167531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
167551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my (%NameSpace_Type) = ();
167561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}})) {
1675774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpace_Type{select_Type_NS($TypeName, 1)}{$TypeName} = 1;
16758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpace_Type))
16760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
167611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= getTitle($HeaderName, "", $NameSpace);
1676274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my @SortedTypes = sort {lc(show_Type($a, 0, 1)) cmp lc(show_Type($b, 0, 1))} keys(%{$NameSpace_Type{$NameSpace}});
16763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $TypeName (@SortedTypes)
16764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemNum = 1;
16766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $TYPE_REPORT = "";
167672489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16770f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
16775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
16776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $TYPE_REPORT .= "<tr><th>$ProblemNum</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>$Effect</td></tr>\n";
16777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemNum += 1;
16778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemsNum += 1;
16779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemNum -= 1;
16783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TYPE_REPORT)
16784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Affected = getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
16786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ShowVTables = "";
167871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ShowVTables = showVTables($TypeName);
16789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1679074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1679174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ".show_Type($TypeName, 1, 1)." ($ProblemNum)".$ContentSpanEnd;
167921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<br/>\n".$ContentDivStart."<table class='ptable'><tr>\n";
167931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th width='2%'></th><th width='47%'>Change</th>\n";
167941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th>Effect</th></tr>".$TYPE_REPORT."</table>\n";
167951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ShowVTables.$Affected."<br/><br/>".$ContentDivEnd."\n";
16796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1679762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $TYPE_PROBLEMS=~s/\b\Q$NameSpace\E::(\w|\~)/$1/g;
16798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
168011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= "<br/>";
16802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168042489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TYPE_PROBLEMS)
16806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = insertIDs($TYPE_PROBLEMS);
168081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Data Types, $TargetSeverity Severity";
168091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Data Types";
16812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
168131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = "<a name=\'".get_Anchor("Type", $Level, $TargetSeverity)."\'></a>\n<h2>$Title ($ProblemsNum)</h2><hr/>\n".$TYPE_PROBLEMS.$TOP_REF."<br/>\n";
16814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TYPE_PROBLEMS;
16817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1681974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub show_Type($$$)
1682074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
1682174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Name, $Html, $LibVersion) = @_;
1682274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TType = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$Name}}{"Type"};
1682374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $TType = lc($TType);
1682474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TType=~/struct|union|enum/) {
1682574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name=~s/\A\Q$TType\E //g;
1682674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1682774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($Html) {
1682874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = "<span class='ttype'>".$TType."</span> ".htmlSpecChars($Name);
1682974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1683074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else {
1683174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = $TType." ".$Name;
1683274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1683374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Name;
1683474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
1683574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
168361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Anchor($$$)
168371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
168381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Kind, $Level, $Severity) = @_;
168391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
168401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
168411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
168421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_".$Level."_Changes_In_".$Kind."s";
168431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
168441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
168451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_".$Level."_Problems_".$Severity;
168461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
168471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
168481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
168491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
168501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
168511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_Changes_In_".$Kind."s";
168521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
168531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
168541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_Problems_".$Severity;
168551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
168561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
168571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
168581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showVTables($)
16860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
16862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId1 = $TName_Tid{1}{$TypeName};
1686362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($TypeId1, 1);
16864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Type1{"VTable"}
16865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$Type1{"VTable"}}))
16866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeId2 = $TName_Tid{2}{$TypeName};
1686862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type2 = get_Type($TypeId2, 2);
16869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Type2{"VTable"}
16870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and keys(%{$Type2{"VTable"}}))
16871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Indexes = map {$_=>1} (keys(%{$Type1{"VTable"}}), keys(%{$Type2{"VTable"}}));
16873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Entries = ();
168741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Index (sort {int($a)<=>int($b)} (keys(%Indexes)))
16875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E1"} = simpleVEntry($Type1{"VTable"}{$Index});
168771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E2"} = simpleVEntry($Type2{"VTable"}{$Index});
16878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $VTABLES = "";
16880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ReportFormat eq "xml")
16881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # XML
16882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      <vtable>\n";
168831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
16884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
168851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "        <entry offset=\"".$Index."\">\n";
168865c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <old>".xmlSpecChars($Entries{$Index}{"E1"})."</old>\n";
168875c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <new>".xmlSpecChars($Entries{$Index}{"E2"})."</new>\n";
16888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $VTABLES .= "        </entry>\n";
16889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      </vtable>\n\n";
16891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # HTML
168941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES .= "<table class='vtable'>";
16895ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<tr><th>Offset</th>";
16896ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (Old) - ".(keys(%{$Type1{"VTable"}}))." entries</th>";
16897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (New) - ".(keys(%{$Type2{"VTable"}}))." entries</th></tr>";
168981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
16899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Color1, $Color2) = ("", "");
169011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Entries{$Index}{"E1"} ne $Entries{$Index}{"E2"})
16902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
169031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Entries{$Index}{"E1"})
16904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
169051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color1 = " class='failed'";
169061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='failed'";
16907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
169091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='warning'";
16910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
169121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<tr><th>".$Index."</th>\n";
169131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color1>".htmlSpecChars($Entries{$Index}{"E1"})."</td>\n";
169141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color2>".htmlSpecChars($Entries{$Index}{"E2"})."</td></tr>\n";
16915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "</table><br/>\n";
16917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES = $ContentDivStart.$VTABLES.$ContentDivEnd;
169181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES = $ContentSpanStart_Info."[+] show v-table (old and new)".$ContentSpanEnd."<br/>\n".$VTABLES;
16919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VTABLES;
16921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
16924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simpleVEntry($)
16927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VEntry = $_[0];
16929dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not defined $VEntry
16930dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    or $VEntry eq "") {
16931dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return "";
16932dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
16933ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
16934ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    $VEntry=~s/ \[.+?\]\Z//; # support for ABI Dumper
16935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A(.+)::(_ZThn.+)\Z/$2/; # thunks
16936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/_ZTI\w+/typeinfo/g; # typeinfo
16937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($VEntry=~/\A_ZThn.+\Z/) {
16938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $VEntry = "non-virtual thunk";
16939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16940fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $VEntry=~s/\A\(int \(\*\)\(...\)\)\s*([a-z_])/$1/i;
16941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # support for old GCC versions
16942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A0u\Z/(int (*)(...))0/;
16943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A4294967268u\Z/(int (*)(...))-0x000000004/;
16944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A&_Z\Z/& _Z/;
16945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/([^:]+)::\~([^:]+)\Z/~$1/; # destructors
16946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VEntry;
16947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16949f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub adjustParamPos($$$)
16950f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
16951f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $Symbol, $LibVersion) = @_;
16952f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol})
16953f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
16954f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$Symbol}{"Static"}
16955f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        and $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
16956f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
16957f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return $Pos-1;
16958f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
16959f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16960f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Pos;
16961f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
16962f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16963f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
16964f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
16965f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16966f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamPos($$$)
16967f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
16968f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
16969f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16970f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
16971f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"})
16972f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
16973f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Info = $CompleteSignature{$LibVersion}{$Symbol};
16974f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach (keys(%{$Info->{"Param"}}))
16975f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
16976f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info->{"Param"}{$_}{"name"} eq $Name)
16977f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
16978f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return $_;
16979f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
16980f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
16981f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
16982f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16983f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
16984f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
16985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16986f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamName($)
16987f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
16988f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Loc = $_[0];
16989f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Loc=~s/\->.*//g;
16990f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $Loc;
16991f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
16992f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16993850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub getAffectedSymbols($$$$)
16994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16995850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Level, $Target_TypeName, $Kinds_Locations, $Syms) = @_;
1699652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $LIMIT = 10;
16997f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16998f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $AffectLimit)
16999f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17000f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $LIMIT = $AffectLimit;
17001f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
1700252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1700352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %SymSel = ();
1700452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my %SymLocKind = ();
1700552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1700652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    foreach my $Symbol (@{$Syms})
17007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
170082489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(index($Symbol, "_Z")==0
170092489ef88760861175102e4508089608391beead3Andrey Ponomarenko        and $Symbol=~/(C2|D2|D0)[EI]/)
17010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # duplicated problems for C2 constructors, D2 and D0 destructors
17011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170132489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1701452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Kind (sort keys(%{$Kinds_Locations}))
17015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170162489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if(not defined $CompatProblems{$Level}{$Symbol}
170172489ef88760861175102e4508089608391beead3Andrey Ponomarenko            or not defined $CompatProblems{$Level}{$Symbol}{$Kind}) {
170182489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next;
170192489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
170202489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1702152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            foreach my $Loc (sort keys(%{$Kinds_Locations->{$Kind}}))
17022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1702352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                if(not defined $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}) {
17024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
170262489ef88760861175102e4508089608391beead3Andrey Ponomarenko
170272489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my ($SN, $SS, $SV) = separate_symbol($Symbol);
170282489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Level eq "Source")
170292489ef88760861175102e4508089608391beead3Andrey Ponomarenko                { # remove symbol version
1703052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                    $Symbol = $SN;
170312489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
170322489ef88760861175102e4508089608391beead3Andrey Ponomarenko
170331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($SV and defined $CompatProblems{$Level}{$SN}
1703452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                and defined $CompatProblems{$Level}{$SN}{$Kind}{$Loc})
17035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicated problems for versioned symbols
17036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
170382489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1703952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                my $Type_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Loc}{"Type_Name"};
170402489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Type_Name ne $Target_TypeName) {
170412489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    next;
170422489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
17043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1704452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymLocKind{$Symbol}{$Loc}{$Kind} = 1;
17045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1704852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1704952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    foreach my $Symbol (sort keys(%SymLocKind))
1705052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
1705152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        LOOP: foreach my $Loc (sort {$a=~/retval/ cmp $b=~/retval/} sort {length($a)<=>length($b)} sort keys(%{$SymLocKind{$Symbol}}))
1705252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        {
1705352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            foreach my $Kind (keys(%{$SymLocKind{$Symbol}{$Loc}}))
1705452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            {
1705552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Loc"} = $Loc;
1705652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $SymSel{$Symbol}{"Kind"} = $Kind;
1705752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1705852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last LOOP;
1705952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1706052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
17061850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
1706252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Affected = "";
1706452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    my $Num = 0;
1706552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
17068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      <affected>\n";
1706952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1707052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17072ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Loc = $SymSel{$Symbol}{"Loc"};
1707352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $PName = getParamName($Loc);
17074ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $SymSel{$Symbol}{"Kind"}, $Loc);
1707552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Target = "";
1707752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($PName)
17078d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            {
1707952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Target .= " param=\"$PName\"";
1708052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                $Desc=~s/parameter $PName /parameter \@param /;
17081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1708252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Aretval(\-|\Z)/i) {
17083d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"retval\"";
17084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1708552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            elsif($Loc=~/\Athis(\-|\Z)/i) {
17086d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " affected=\"this\"";
17087d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            }
17088d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1708952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Desc=~s/\AField ([^\s]+) /Field \@field /) {
17090d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko                $Target .= " field=\"$1\"";
17091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17092d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17093d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            $Affected .= "        <symbol name=\"$Symbol\"$Target>\n";
1709452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "          <comment>".xmlSpecChars($Desc)."</comment>\n";
17095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "        </symbol>\n";
1709652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1709752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Num>$LIMIT) {
1709852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last LOOP;
1709952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1710052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1710152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Num += 1;
17102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      </affected>\n";
17104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
1710752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Symbol (sort {lc($a) cmp lc($b)} keys(%SymSel))
17108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1710952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Desc = getAffectDesc($Level, $Symbol, $SymSel{$Symbol}{"Kind"}, $SymSel{$Symbol}{"Loc"});
1711052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $S = get_Signature($Symbol, 1);
1711101e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko            my $PName = getParamName($SymSel{$Symbol}{"Loc"});
1711252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            my $Pos = adjustParamPos(getParamPos($PName, $Symbol, 1), $Symbol, 1);
1711352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1711452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "<span class='iname_a'>".highLight_Signature_PPos_Italic($S, $Pos, 1, 0, 0)."</span><br/>";
1711552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected .= "<div class='affect'>".htmlSpecChars($Desc)."</div>\n";
1711652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1711752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            if($Num>$LIMIT) {
1711852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko                last;
1711952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            }
1712052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1712152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Num += 1;
17122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1712352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1712452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(keys(%SymSel)>$LIMIT) {
171252489ef88760861175102e4508089608391beead3Andrey Ponomarenko            $Affected .= " ...<br/>"; # and others ...
17126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1712752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17128850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Affected = "<div class='affected'>".$Affected."</div>";
17129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Affected)
17130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected = $ContentDivStart.$Affected.$ContentDivEnd;
1713252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Affected = $ContentSpanStart_Affected."[+] affected symbols (".keys(%SymSel).")".$ContentSpanEnd.$Affected;
17133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
171352489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Affected;
17137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17139f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub cmpLocations($$)
17140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1714162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($L1, $L2) = @_;
17142f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($L2=~/\A(retval|this)\b/
17143f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and $L1!~/\A(retval|this)\b/)
17144f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17145f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($L1!~/\-\>/) {
17146f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17147f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17148f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($L2=~/\-\>/) {
17149f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17150f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
17153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17155f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getAffectDesc($$$$)
17156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
171571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Symbol, $Kind, $Location) = @_;
17158f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
171591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my %Problem = %{$CompatProblems{$Level}{$Symbol}{$Kind}{$Location}};
17160f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17161f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Location_I = $Location;
17162f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Location=~s/\A(.*)\-\>(.+?)\Z/$1/; # without the latest affected field
17163f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Sentence = ();
17165f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Kind eq "Overridden_Virtual_Method"
17167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Kind eq "Overridden_Virtual_Method_B") {
17168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Sentence, "The method '".$Problem{"New_Value"}."' will be called instead of this method.");
17169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
17171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17172f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %SymInfo = %{$CompleteSignature{1}{$Symbol}};
17173f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Location eq "this" or $Kind=~/(\A|_)Virtual(_|\Z)/)
17175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17176f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $METHOD_TYPE = $SymInfo{"Constructor"}?"constructor":"method";
17177f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $ClassName = $TypeInfo{1}{$SymInfo{"Class"}}{"Name"};
17178f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ClassName eq $Problem{"Type_Name"}) {
17180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from \'".$Problem{"Type_Name"}."\' class.");
17181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from derived class \'".$ClassName."\'.");
17184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
17187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17188f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $TypeID = undef;
17189f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location=~/retval/)
17191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # return value
17192f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in return value");
17194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Return value");
17197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17198f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17199f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Return"};
17200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/this/)
17202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "this" pointer
17203f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in the object of this method");
17205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'this\' pointer");
17208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17209f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17210f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Class"};
17211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # parameters
17214f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17215f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PName = getParamName($Location);
17216f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PPos = getParamPos($PName, $Symbol, 1);
17217f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17218f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17219f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in ".showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17222f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17224f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($PName) {
17225f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "\'".$PName."\'");
17226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17227f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17228f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Param"}{$PPos}{"type"};
17229f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17230f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17231f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Location!~/this/)
17232f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17233f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(my %PureType = get_PureType($TypeID, $TypeInfo{1}))
17234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17235f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($PureType{"Type"} eq "Pointer") {
17236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17237dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17238f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    elsif($PureType{"Type"} eq "Ref") {
17239dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17243f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location eq "this") {
17245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17247f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            else
17248f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17249f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Location_T = $Location;
17250f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $Location_T=~s/\A\w+(\->|\Z)//; # location in type
17251f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17252f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $TypeID_Problem = $TypeID;
17253f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($Location_T) {
17254f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeID_Problem = getFieldType($Location_T, $TypeID, 1);
17255f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17256f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17257f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($TypeInfo{1}{$TypeID_Problem}{"Name"} eq $Problem{"Type_Name"}) {
17258f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has type \'".$Problem{"Type_Name"}."\'.");
17259f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17260f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                else {
17261f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17262f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1726662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($ExtendedSymbols{$Symbol}) {
172678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        push(@Sentence, " This is a symbol from an external library that may use the \'$TargetLibraryName\' library and change the ABI after recompiling.");
17268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17269d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17270d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my $Sent = join(" ", @Sentence);
17271d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1727252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Sent=~s/->/./g;
1727352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17274d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if($ReportFormat eq "xml")
17275d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    {
17276d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Sent=~s/'//g;
17277d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
17278d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17279d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    return $Sent;
17280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17282f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getFieldType($$$)
17283f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17284f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Location, $TypeId, $LibVersion) = @_;
17285f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17286d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    my @Fields = split(/\->/, $Location);
17287f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17288f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $Name (@Fields)
17289f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17290f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %Info = get_BaseType($TypeId, $LibVersion);
17291f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17292f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Pos (keys(%{$Info{"Memb"}}))
17293f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17294f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info{"Memb"}{$Pos}{"name"} eq $Name)
17295f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17296f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeId = $Info{"Memb"}{$Pos}{"type"};
17297f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                last;
17298f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17299f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17300f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17301f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17302f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $TypeId;
17303f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17304f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_XmlSign($$)
17306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
17308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "";
17310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Info->{"Param"}}))
17311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Name = $Info->{"Param"}{$Pos}{"name"};
1731362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Type = $Info->{"Param"}{$Pos}{"type"};
1731462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TypeName = $TypeInfo{$LibVersion}{$Type}{"Name"};
17315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
17316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
173178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
173188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeName=~s/\b\Q$Typedef\E\b/$Base/g;
173198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
17320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <param pos=\"$Pos\">\n";
17322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "      <name>".$Name."</name>\n";
173235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($TypeName)."</type>\n";
17324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </param>\n";
17325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Return = $Info->{"Return"})
17327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1732862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $RTName = $TypeInfo{$LibVersion}{$Return}{"Name"};
17329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <retval>\n";
173305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($RTName)."</type>\n";
17331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </retval>\n";
17332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
173361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_SymbolsInfo($)
17337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
173381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "<symbols_info>\n";
173401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
17341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
173421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
173431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
17344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  <symbol name=\"$Symbol\">\n";
17347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($S1, $P1, $S2, $P2) = ();
173481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $AddedInt{$Level}{$Symbol})
17349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{1}{$Symbol}
17351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{1}{$Symbol}{"Header"})
17352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P1 = get_XmlSign($Symbol, 1);
17354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = get_Signature($Symbol, 1);
17355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = $tr_name{$Symbol};
17358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
173601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $RemovedInt{$Level}{$Symbol})
17361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$Symbol}
17363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{2}{$Symbol}{"Header"})
17364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P2 = get_XmlSign($Symbol, 2);
17366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = get_Signature($Symbol, 2);
17367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = $tr_name{$Symbol};
17370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S1)
17373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
173745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <old signature=\"".xmlSpecChars($S1)."\">\n";
17375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P1;
17376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </old>\n";
17377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S2 and $S2 ne $S1)
17379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
173805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <new signature=\"".xmlSpecChars($S2)."\">\n";
17381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P2;
17382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </new>\n";
17383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  </symbol>\n";
17385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report .= "</symbols_info>\n";
17387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
173901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub writeReport($$)
17391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
173921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Report) = @_;
173931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($ReportFormat eq "xml") {
173941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".$Report;
173951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
173961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
173971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --stdout option
173981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        print STDOUT $Report;
173991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
174001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
174011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
174021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $RPath = getReportPath($Level);
17403850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        mkpath(get_dirname($RPath));
17404850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
17405850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(REPORT, ">", $RPath) || die ("can't open file \'$RPath\': $!\n");
17406850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        print REPORT $Report;
17407850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(REPORT);
1740862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1740962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1741062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
174111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReport($)
174121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
174131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
174161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
174171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
174181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<reports>\n";
174191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Binary");
174201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Source");
174211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</reports>\n";
174221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
174231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
174241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
174251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
174261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<report kind=\"".lc($Level)."\" version=\"$XML_REPORT_VERSION\">\n\n";
174271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
174281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= $Summary."\n";
174291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
174301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
17431d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
17432d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # additional symbols info (if needed)
17433d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko            # $Report .= get_Report_SymbolsInfo($Level);
17434d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
174351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</report>\n";
174361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
174371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
174411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $CssStyles = readModule("Styles", "Report.css");
174421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $JScripts = readModule("Scripts", "Sections.js");
174431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
174441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
174451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CssStyles .= "\n".readModule("Styles", "Tabs.css");
174461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JScripts .= "\n".readModule("Scripts", "Tabs.js");
1744714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." compatibility report";
1744841834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Keywords = $TargetTitle.", compatibility, API, ABI, report";
1744941834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            my $Description = "API/ABI compatibility report for the $TargetTitle $TargetComponent between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
174501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($BSummary, $BMetaData) = get_Summary("Binary");
174511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SSummary, $SMetaData) = get_Summary("Source");
174521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
1745352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title("Join")."
174541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            <br/><div class='tabset'>
174551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
174561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
174571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            </div>";
174581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
174591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
1746041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1746152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
174621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
174631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
174641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
174651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
174661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
1746714b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Title = $TargetTitle.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." ".lc($Level)." compatibility report";
1746814b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Keywords = $TargetTitle.", ".lc($Level)." compatibility, API, report";
1746914b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            my $Description = "$Level compatibility report for the ".$TargetTitle." ".$TargetComponent." between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
174701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
174711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
174721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(getArch(1) eq getArch(2)
174731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and getArch(1) ne "unknown") {
174741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Description .= " on ".showArch(getArch(1));
174751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
174761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
174771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $MetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."\n<body>\n<div><a name='Top'></a>\n";
1747852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= get_Report_Title($Level)."\n".$Summary."\n";
174791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
174801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
174811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_SourceInfo();
1748241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= "</div>\n<br/><br/><br/>\n";
1748341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko            $Report .= getReportFooter();
1748452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $Report .= "\n</body></html>\n";
174851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
174861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
174881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
174891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
174901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getLegend()
174911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
174921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "<br/>
174931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<table class='summary'>
174941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
174951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='new'>added</td>
174961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='passed'>compatible</td>
174971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr>
174981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
174991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='warning'>warning</td>
175001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='failed'>incompatible</td>
175011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr></table>\n";
175021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
175031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
175041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub createReport()
175051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
175061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
175070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # --stdout
175081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Join", getReport("Join"));
17509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
175101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($DoubleReport)
175111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
175121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
175131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
175141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
175151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
175161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
175171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
175181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
175191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
175201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
175211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
17522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1752541834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenkosub getReportFooter()
17526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1752741834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    my $Footer = "";
1752801e8e504067a2495b8fa063b7fd579e5a64b297aAndrey Ponomarenko
1752941834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<hr/>";
1753041834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<div class='footer' align='right'><i>Generated on ".localtime(time);
17531ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    $Footer .= " by <a href='".$HomePage."'>ABI Compliance Checker</a> $TOOL_VERSION &#160;";
1753252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $Footer .= "</i></div>";
1753341834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    $Footer .= "<br/>\n";
1753441834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko
17535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Footer;
17536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Problems($$)
17539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
175402489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my ($Severity, $Level) = @_;
1754152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
175422489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my $Report = get_Report_TypeProblems($Severity, $Level);
175432489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if(my $SProblems = get_Report_SymbolProblems($Severity, $Level)) {
175441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Report .= $SProblems;
17545dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1754652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
1754752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($Severity eq "Low" or $Severity eq "Safe") {
1754852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        $Report .= get_Report_ChangedConstants($Severity, $Level);
175498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1755052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
17551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "html")
17552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Report)
17554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add anchor
175551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport)
175561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
175572489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
175581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_".$Level."_Changes\'></a>".$Report;
175591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
175601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
175612489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_".$Level."_Problems\'></a>".$Report;
175621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
175641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
175651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
175662489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
175671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_Changes\'></a>".$Report;
175681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
175691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
175702489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_Problems\'></a>".$Report;
175711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
175781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub composeHTML_Head($$$$$)
17579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
175801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Title, $Keywords, $Description, $Styles, $Scripts) = @_;
175811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
175821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
175831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <head>
17584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
17585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"keywords\" content=\"$Keywords\" />
17586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"description\" content=\"$Description\" />
175871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <title>
175881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title
175891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </title>
175901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <style type=\"text/css\">
175911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Styles
175921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </style>
175931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <script type=\"text/javascript\" language=\"JavaScript\">
175941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <!--
175951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Scripts
175961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    -->
175971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </script>
175981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </head>";
17599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub insertIDs($)
17602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Text = $_[0];
17604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Text=~/CONTENT_ID/)
17605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($Content_Counter)%2) {
17607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ContentID -= 1;
17608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Text=~s/CONTENT_ID/c_$ContentID/;
17610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ContentID += 1;
17611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content_Counter += 1;
17612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Text;
17614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkPreprocessedUnit($)
17617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
17619a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my ($CurHeader, $CurHeaderName) = ("", "");
1762074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $CurClass = ""; # extra info
176211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    open(PREPROC, $Path) || die ("can't open file \'$Path\': $!\n");
1762274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17623a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    while(my $Line = <PREPROC>)
176241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting public and private constants
17625a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(substr($Line, 0, 1) eq "#")
17626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17627a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            chomp($Line);
17628a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if($Line=~/\A\#\s+\d+\s+\"(.+)\"/)
17629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17630a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeader = path_format($1, $OSgroup);
17631a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeaderName = get_filename($CurHeader);
1763274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CurClass = "";
1763374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1763474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(index($CurHeader, $TMP_DIR)==0) {
1763574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    next;
1763674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1763774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17638fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(substr($CurHeaderName, 0, 1) eq "<")
17639fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # <built-in>, <command-line>, etc.
17640fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeaderName = "";
17641fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeader = "";
17642fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17643fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1764474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($ExtraInfo)
1764574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
17646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
1764774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $PreprocessedHeaders{$Version}{$CurHeader} = 1;
1764874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
1764974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
17650a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
1765174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not $ExtraDump)
176524b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            {
17653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($CurHeaderName)
17654fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17655fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $Include_Neighbors{$Version}{$CurHeaderName}
17656fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $Registered_Headers{$Version}{$CurHeader})
17657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # not a target
17658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not is_target_header($CurHeaderName, 1)
17661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not is_target_header($CurHeaderName, 2))
17662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # user-defined header
17663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
176654b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                }
17666a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
176674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
176689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Line=~/\A\#\s*define\s+(\w+)\s+(.+)\s*\Z/)
17669a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
17670a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
17671a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if(not $Constants{$Version}{$Name}{"Access"})
17672a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
17673a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Access"} = "public";
17674a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Value"} = $Value;
17675fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
17676fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Constants{$Version}{$Name}{"Header"} = $CurHeaderName;
17677fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17678a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
17679a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
17680a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            elsif($Line=~/\A\#[ \t]*undef[ \t]+([_A-Z]+)[ \t]*/) {
17681a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Constants{$Version}{$1}{"Access"} = "private";
17682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1768474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
1768574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1768674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $ExtraDump)
1768774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1768874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/(\w+)\s*\(/)
1768974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # functions
1769074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1769174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1769274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #elsif($Line=~/(\w+)\s*;/)
1769374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #{ # data
1769474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1769574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #}
1769674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                elsif($Line=~/(\A|\s)class\s+(\w+)/) {
1769774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CurClass = $2;
1769874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1769974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1770074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
17703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
17704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1770574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Constants{$Version}{$Constant}{"Access"} eq "private")
1770674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1770774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
1770874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            next;
1770974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
17710177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ExtraDump and ($Constant=~/_h\Z/i
17711177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or isBuiltIn($Constants{$Version}{$Constant}{"Header"})))
1771274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # skip
1771374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
17714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
17716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($Constants{$Version}{$Constant}{"Access"});
17717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17719a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug)
17720a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
17721a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
17722a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        copy($Path, $DEBUG_PATH{$Version}."/preprocessor.txt");
17723a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
17724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
177261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub uncoverConstant($$)
177271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
177281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($LibVersion, $Constant) = @_;
177291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "" if(not $LibVersion or not $Constant);
177301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Constant if(isCyclical(\@RecurConstant, $Constant));
177311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"uncoverConstant"}{$LibVersion}{$Constant}) {
177321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"uncoverConstant"}{$LibVersion}{$Constant};
177331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
17734fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17735fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Constants{$LibVersion}{$Constant})
177361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
17737fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value = $Constants{$LibVersion}{$Constant}{"Value"};
17738fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$LibVersion}{$Value})
177391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
177401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            push(@RecurConstant, $Constant);
177411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $Uncovered = uncoverConstant($LibVersion, $Value);
177421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Uncovered ne "") {
177431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Value = $Uncovered;
177441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
177451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            pop(@RecurConstant);
177461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
17747fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
177481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # FIXME: uncover $Value using all the enum constants
17749fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # USE CASE: change of define NC_LONG from NC_INT (enum value) to NC_INT (define)
177501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = $Value);
177511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
177521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = "");
177531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
177541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
17755fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub simpleConstant($$)
17756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
17757fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Value) = @_;
17758fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\W/)
17759fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
17760fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value_Copy = $Value;
17761fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        while($Value_Copy=~s/([a-z_]\w+)/\@/i)
17762fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
17763fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Word = $1;
17764fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($Value!~/$Word\s*\(/)
17765fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
17766fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Val = uncoverConstant($LibVersion, $Word);
17767fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Val ne "")
17768fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17769fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Value=~s/\b$Word\b/$Val/g;
17770fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17771fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17772fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17773fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17774fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
17775fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
17776fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17777fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub computeValue($)
17778fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
17779fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $Value = $_[0];
17780fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17781fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A\((-?[\d]+)\)\Z/) {
17782fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return $1;
17783fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17784fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17785fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A[\d\-\+()]+\Z/) {
17786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return eval($Value);
17787fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
17788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
17790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
17791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
177929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %IgnoreConstant = map {$_=>1} (
177939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSION",
177949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSIONCODE",
177959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERNUM",
177969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERS_INFO",
177979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCHLEVEL",
177989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLPREFIX",
177999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VBUILD",
178009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VPATCH",
178019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VMINOR",
178029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_STRING",
178039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_TIME",
178049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_STRING",
178059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PRODUCTION",
178069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIGURE_COMMAND",
178079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLDIR",
178089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINDIR",
178099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIG_FILE_PATH",
178109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DATADIR",
178119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "EXTENSION_DIR",
178129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INCLUDE_PATH",
178139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LIBDIR",
178149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LOCALSTATEDIR",
178159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SBINDIR",
178169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SYSCONFDIR",
178179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "RELEASE",
178189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SOURCE_ID",
178199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SUBMINOR",
178209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINOR",
178219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINNOR",
178229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINORVERSION",
178239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJOR",
178249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJORVERSION",
178259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICRO",
178269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICROVERSION",
178279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINARY_AGE",
178289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INTERFACE_AGE",
178299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CORE_ABI",
178309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCH",
178319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COPYRIGHT",
178329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "TIMESTAMP",
178339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "REVISION",
178349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_TAG",
178359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGEDATE",
178369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NUMVERSION",
178379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Release",
178389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Version"
17839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
17840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
178418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub constantFilter($$$)
178428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
178438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Name, $Value, $Level) = @_;
178448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
178458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Level eq "Binary")
178468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
17847fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Name=~/_t\Z/)
17848fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # __malloc_ptr_t
17849fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
17850fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
178518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach (keys(%IgnoreConstant))
178528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
178538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Name=~/(\A|_)$_(_|\Z)/)
178548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # version
178558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
178568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
178578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(/\A[A-Z].*[a-z]\Z/)
178588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
178598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Name=~/(\A|[a-z])$_([A-Z]|\Z)/)
178608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # version
178618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return 1;
178628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
178638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
178648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
178658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Name=~/(\A|_)(lib|open|)$TargetLibraryShortName(_|)(VERSION|VER|DATE|API|PREFIX)(_|\Z)/i)
178668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # version
178678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
178688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
178698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Value=~/\A('|"|)[\/\\]\w+([\/\\]|:|('|"|)\Z)/ or $Value=~/[\/\\]\w+[\/\\]\w+/)
178708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # /lib64:/usr/lib64:/lib:/usr/lib:/usr/X11R6/lib/Xaw3d ...
178718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
178728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17873fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17874fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A["'].*['"]/i)
17875fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # string
17876fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
17877fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17878fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17879fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[({]*\s*[a-z_]+\w*(\s+|[\|,])/i)
17880fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # static int gcry_pth_init
17881fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # extern ABC
178828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # (RE_BACKSLASH_ESCAPE_IN_LISTS | RE...
17883fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # { H5FD_MEM_SUPER, H5FD_MEM_SUPER, ...
178848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
178858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17886fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\w+\s*\(/i)
178878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # foo(p)
178888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
178898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
17890fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[a-z_]+\w*\Z/i)
178918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # asn1_node_st
17892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # __SMTH_P
178938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
178948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
178958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
178968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
178978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
178988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
178998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeConstants($)
17901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
179021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{1}}))
17904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipConstants{1}{$Constant})
17906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skipped by the user
17907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
179098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
17910fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Header = $Constants{1}{$Constant}{"Header"})
17911fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
17912fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not is_target_header($Header, 1)
17913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and not is_target_header($Header, 2))
17914fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # user-defined header
17915fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
17916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
17918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        else {
17919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
179218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value = uncoverConstant(1, $Constant);
179238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(constantFilter($Constant, $Old_Value, $Level))
179258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # separate binary and source problems
179268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
179278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{2}{$Constant}{"Value"})
179308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # removed
179318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Removed_Constant"}} = (
179328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
179338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Old_Value"=>$Old_Value  );
179348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
179358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Constants{2}{$Constant}{"Value"} eq "")
179388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # empty value
179398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # TODO: implement a rule
179408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
179418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
179428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value = uncoverConstant(2, $Constant);
179448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value_Pure = $Old_Value;
179468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value_Pure = $New_Value;
179478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
17948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/(\W)\s+/$1/g;
17949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/\s+(\W)/$1/g;
17950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/(\W)\s+/$1/g;
17951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/\s+(\W)/$1/g;
179528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
17953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($New_Value_Pure eq "" or $Old_Value_Pure eq "");
17954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
17955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($New_Value_Pure ne $Old_Value_Pure)
17956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different values
17957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(simpleConstant(1, $Old_Value) eq simpleConstant(2, $New_Value))
17958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # complex values
17959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
17960fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(computeValue($Old_Value) eq computeValue($New_Value))
17962fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # expressions
17963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
17964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
17965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(convert_integer($Old_Value) eq convert_integer($New_Value))
17966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0x0001 and 0x1, 0x1 and 1 equal constants
17967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
17968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "0" and $New_Value eq "NULL")
17970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0 => NULL
17971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
17972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "NULL" and $New_Value eq "0")
17974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # NULL => 0
17975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
17976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
179778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Changed_Constant"}} = (
17978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Constant,
17979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Value"=>$Old_Value,
17980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Value"=>$New_Value  );
17981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
179838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
179848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$Constants{2}}))
179858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
179868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{1}{$Constant}{"Value"})
179878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
179888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SkipConstants{2}{$Constant})
179898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # skipped by the user
179908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
179918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
179928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
17993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $Header = $Constants{2}{$Constant}{"Header"})
17994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
17995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(not is_target_header($Header, 1)
17996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not is_target_header($Header, 2))
17997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # user-defined header
17998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    next;
17999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18000fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
180028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $New_Value = uncoverConstant(2, $Constant);
180068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $New_Value or $New_Value eq "") {
180078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(constantFilter($Constant, $New_Value, $Level))
180118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # separate binary and source problems
180128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
180138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
180148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
180158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Added_Constant"}} = (
180168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
180178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "New_Value"=>$New_Value  );
180188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
180198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
18020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub convert_integer($)
18023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Value = $_[0];
18025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Value=~/\A0x[a-f0-9]+\Z/)
180261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # hexadecimal
18027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return hex($Value);
18028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0[0-7]+\Z/)
180301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # octal
18031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0b[0-1]+\Z/)
180341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # binary
18035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
18038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Value;
18039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
180421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols($)
18043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1804562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @LibPaths = getSOPaths($LibVersion);
180461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($#LibPaths==-1 and not $CheckHeadersOnly)
18047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibVersion==1)
18049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
18051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
18052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries are not found in ".$Descriptor{$LibVersion}{"Version"});
18055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18057570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
180584b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $LibPath (@LibPaths) {
180599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        readSymbols_Lib($LibVersion, $LibPath, 0, "+Weak", 1, 1);
18060570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18061570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18062570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($CheckUndefined)
18063570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18064570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my %UndefinedLibs = ();
18065570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1806674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Libs = (keys(%{$Library_Symbol{$LibVersion}}), keys(%{$DepLibrary_Symbol{$LibVersion}}));
1806774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1806874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $LibName (sort @Libs)
18069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
1807074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $UndefinedSymbols{$LibVersion}{$LibName})
18071570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
1807274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                foreach my $Symbol (keys(%{$UndefinedSymbols{$LibVersion}{$LibName}}))
18073570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Symbol_Library{$LibVersion}{$Symbol}
18075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $DepSymbol_Library{$LibVersion}{$Symbol})
18076fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported by target library
18077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(index($Symbol, '@')!=-1)
18080fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported default symbol version (@@)
18081fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Symbol=~s/\@/\@\@/;
18082fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Symbol_Library{$LibVersion}{$Symbol}
18083fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or $DepSymbol_Library{$LibVersion}{$Symbol}) {
18084fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            next;
1808574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        }
18086570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18087fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $Path (find_SymbolLibs($LibVersion, $Symbol)) {
18088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $UndefinedLibs{$Path} = 1;
18089fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18090570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18091570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18092570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18093570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($ExtraInfo)
18094570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # extra information for other tools
18095fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my @Paths = sort keys(%UndefinedLibs))
18096570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18097570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $LibString = "";
18098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my %Dirs = ();
18099570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach (@Paths)
18100570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
1810174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $KnownLibs{$_} = 1;
18102570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    my ($Dir, $Name) = separate_path($_);
18103570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18104570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Dir eq $_} (@{$SystemPaths{"lib"}})) {
18105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Dirs{esc($Dir)} = 1;
18106570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18107570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18108570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name = parse_libname($Name, "name", $OStarget);
18109570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name=~s/\Alib//;
18110570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1811174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $LibString .= " -l$Name";
18112570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18113fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18114fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Dir (sort {$b cmp $a} keys(%Dirs))
18115fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18116fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $LibString = " -L".esc($Dir).$LibString;
18117fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18118fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18119570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                writeFile($ExtraInfo."/libs-string", $LibString);
18120570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18121570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
181221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18123570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1812474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo) {
1812574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/lib-paths", join("\n", sort keys(%KnownLibs)));
1812674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1812774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
181281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $CheckHeadersOnly)
181291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
181301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($#LibPaths!=-1)
181311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
181321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$Symbol_Library{$LibVersion}}))
181331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
181340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                printMsg("WARNING", "the set of public symbols in library(ies) is empty ($LibVersion)");
181351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                printMsg("WARNING", "checking headers only");
181361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $CheckHeadersOnly = 1;
181371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
181381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1814107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko   # clean memory
18142850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko   %SystemObjects = ();
18143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18145570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Prefix_Lib_Map=(
18146570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by prefix)
18147570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pthread_" => ["libpthread"],
18148570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "g_" => ["libglib-2.0", "libgobject-2.0", "libgio-2.0"],
18149570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cairo_" => ["libcairo"],
18150570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gtk_" => ["libgtk-x11-2.0"],
18151570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "atk_" => ["libatk-1.0"],
18152570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gdk_" => ["libgdk-x11-2.0"],
18153570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gl" => ["libGL"],
18154570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "glu" => ["libGLU"],
18155570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "popt" => ["libpopt"],
18156570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Py" => ["libpython"],
18157570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "jpeg_" => ["libjpeg"],
18158570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "BZ2_" => ["libbz2"],
18159570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Fc" => ["libfontconfig"],
18160570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Xft" => ["libXft"],
18161570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SSL_" => ["libssl"],
18162570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sem_" => ["libpthread"],
18163570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "snd_" => ["libasound"],
18164570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "art_" => ["libart_lgpl_2"],
18165570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dbus_g" => ["libdbus-glib-1"],
18166570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "GOMP_" => ["libgomp"],
18167570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "omp_" => ["libgomp"],
18168570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cms" => ["liblcms"]
18169570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18170570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18171570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Pattern_Lib_Map=(
18172570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SL[a-z]" => ["libslang"]
18173570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18174570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18175570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Symbol_Lib_Map=(
18176570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by name)
18177570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pow" => "libm",
18178570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "fmod" => "libm",
18179570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sin" => "libm",
18180570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "floor" => "libm",
18181570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cos" => "libm",
18182570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dlopen" => "libdl",
18183570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "deflate" => "libz",
18184570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "inflate" => "libz",
18185570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "move_panel" => "libpanel",
18186570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "XOpenDisplay" => "libX11",
18187570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "resize_term" => "libncurses",
181888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "clock_gettime" => "librt",
181898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "crypt" => "libcrypt"
18190570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18191570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub find_SymbolLibs($$)
18193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18194570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Symbol) = @_;
18195570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18196570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(index($Symbol, "g_")==0 and $Symbol=~/[A-Z]/)
18197570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # debug symbols
18198570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return ();
18199570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18200570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18201570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %Paths = ();
18202570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18203570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $LibName = $Symbol_Lib_Map{$Symbol})
18204570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18205570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18206570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Paths{$Path} = 1;
18207570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18208570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18209570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18210570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $SymbolPrefix = getPrefix($Symbol))
18211570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18212570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(defined $Cache{"find_SymbolLibs"}{$SymbolPrefix}) {
18213570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return @{$Cache{"find_SymbolLibs"}{$SymbolPrefix}};
18214570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18215570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18216570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18217570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18218570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(defined $Prefix_Lib_Map{$SymbolPrefix})
18219570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18220570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $LibName (@{$Prefix_Lib_Map{$SymbolPrefix}})
18221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18223570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18224570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18225570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18226570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18227570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18228570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18229570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18230570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18231570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Prefix (sort keys(%Pattern_Lib_Map))
18232570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18233570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Symbol=~/\A$Prefix/)
18234570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18235570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    foreach my $LibName (@{$Pattern_Lib_Map{$Prefix}})
18236570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18237570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18238570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                            $Paths{$Path} = 1;
18239570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18240570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18241570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18242570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18243570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18244570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18245570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18246570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18247570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($SymbolPrefix)
18248570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # try to find a library by symbol prefix
18249570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($SymbolPrefix eq "inotify" and
18250570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                index($Symbol, "\@GLIBC")!=-1)
18251570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18252570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, "libc.$LIB_EXT")) {
18253570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18254570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18255570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18256570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else
18257570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18258570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath_Prefix($LibVersion, $SymbolPrefix)) {
18259570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18260570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18261570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18262570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18263570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18264570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18265570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my @Paths = keys(%Paths)) {
18266570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cache{"find_SymbolLibs"}{$SymbolPrefix} = \@Paths;
18267570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18268570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18269570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return keys(%Paths);
18270570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18271570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18272570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub get_LibPath_Prefix($$)
18273570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18274570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Prefix) = @_;
18275570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18276570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix = lc($Prefix);
18277570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix=~s/[_]+\Z//g;
18278570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18279570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach ("-2", "2", "-1", "1", "")
18280570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # libgnome-2.so
18281570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libxml2.so
18282570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libdbus-1.so
18283570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, "lib".$Prefix.$_.".".$LIB_EXT)) {
18284570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return $Path;
18285570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18286570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18287570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18288570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18289570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18290570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub getPrefix($)
18291570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18292570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Str = $_[0];
18293570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Str=~/\A([_]*[A-Z][a-z]{1,5})[A-Z]/)
18294570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XmuValidArea: Xmu
18295570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18296570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18297570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]+)[A-Z]/)
18298570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # snfReadFont: snf
18299570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18300570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18301570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[A-Z]{2,})[A-Z][a-z]+([A-Z][a-z]+|\Z)/)
18302570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XRRTimes: XRR
18303570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18304570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18305570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]{1,2}\d+)[a-z\d]*_[a-z]+/i)
18306570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # H5HF_delete: H5
18307570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18308570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18309570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z0-9]{2,}_)[a-z]+/i)
18310570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # alarm_event_add: alarm_
18311570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18312570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18313570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A(([a-z])\2{1,})/i)
18314570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # ffopen
18315570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18316570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18317570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18318570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18319570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
183201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getSymbolSize($$)
183211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # size from the shared library
183221693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
183231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0 if(not $Symbol);
183241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Symbol_Library{$LibVersion}{$Symbol}
183251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    and my $LibName = $Symbol_Library{$LibVersion}{$Symbol})
183261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
183271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Library_Symbol{$LibVersion}{$LibName}{$Symbol}
183281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        and my $Size = $Library_Symbol{$LibVersion}{$LibName}{$Symbol})
183291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
183301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Size<0) {
183311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return -$Size;
18332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
183351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0;
18336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1833807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub canonifyName($$)
18339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # make TIFFStreamOpen(char const*, std::basic_ostream<char, std::char_traits<char> >*)
18340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # to be TIFFStreamOpen(char const*, std::basic_ostream<char>*)
1834107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Name, $Type) = @_;
1834207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1834307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # single
1834407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    while($Name=~/([^<>,]+),\s*$DEFAULT_STD_PARMS<([^<>,]+)>\s*/ and $1 eq $3)
18345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18346850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $P = $1;
1834707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Name=~s/\Q$P\E,\s*$DEFAULT_STD_PARMS<\Q$P\E>\s*/$P/g;
18348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1834907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1835007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # double
1835107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($Name=~/$DEFAULT_STD_PARMS/)
1835207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
18353e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Type eq "S")
1835407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1835507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortName, $FuncParams) = split_Signature($Name);
1835607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1835707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            foreach my $FParam (separate_Params($FuncParams, 0, 0))
1835807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
1835907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                if(index($FParam, "<")!=-1)
1836007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                {
1836107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $FParam=~s/>([^<>]+)\Z/>/; # remove quals
1836207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    my $FParam_N = canonifyName($FParam, "T");
1836307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    if($FParam_N ne $FParam) {
1836407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                        $Name=~s/\Q$FParam\E/$FParam_N/g;
1836507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    }
1836607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1836707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1836807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1836907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        elsif($Type eq "T")
1837007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1837107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortTmpl, $TmplParams) = template_Base($Name);
1837207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1837307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my @TParams = separate_Params($TmplParams, 0, 0);
18374e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($#TParams>=1)
1837507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
18376e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                my $FParam = $TParams[0];
18377e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                foreach my $Pos (1 .. $#TParams)
18378e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                {
18379e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    my $TParam = $TParams[$Pos];
18380e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    if($TParam=~/\A$DEFAULT_STD_PARMS<\Q$FParam\E\s*>\Z/) {
18381e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                        $Name=~s/\Q$FParam, $TParam\E\s*/$FParam/g;
18382e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    }
1838307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1838407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1838507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1838607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
18387e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($Type eq "S") {
18388e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        return formatName($Name, "S");
18389e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
18390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
18391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18393dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub translateSymbols(@)
18394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = pop(@_);
1839662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my (@MnglNames1, @MnglNames2, @UnmangledNames) = ();
183979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $Symbol (sort @_)
18398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
183999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_Z")==0)
18400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
184019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next if($tr_name{$Symbol});
184029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Symbol=~s/[\@\$]+(.*)\Z//;
184039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames1, $Symbol);
18404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18405570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        elsif(index($Symbol, "?")==0)
18406570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18407570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            next if($tr_name{$Symbol});
184089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames2, $Symbol);
18409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
18411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # not mangled
184129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $tr_name{$Symbol} = $Symbol;
184139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name_gcc{$Symbol} = $Symbol;
184149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name{$LibVersion}{$Symbol} = $Symbol;
18415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames1 > -1)
18418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC names
1841962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames1));
18420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames1)
18421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1842262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1842362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1842472930b9bbe1284ca8eee0f5a2728d5bf094400e5Andrey Ponomarenko                $tr_name{$MnglName} = canonifyName($Unmangled, "S");
1842562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $mangled_name_gcc{$tr_name{$MnglName}}) {
1842662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $mangled_name_gcc{$tr_name{$MnglName}} = $MnglName;
1842762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
184289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($MnglName, "_ZTV")==0
1842962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                and $tr_name{$MnglName}=~/vtable for (.+)/)
1843062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # bind class name and v-table symbol
1843162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $ClassName = $1;
1843262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ClassVTable{$ClassName} = $MnglName;
1843362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $VTableClass{$MnglName} = $ClassName;
1843462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
18435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames2 > -1)
18439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC names
1844062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames2));
18441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames2)
18442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1844362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1844462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
184459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $tr_name{$MnglName} = formatName($Unmangled, "S");
1844662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $mangled_name{$LibVersion}{$tr_name{$MnglName}} = $MnglName;
1844762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
18448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%tr_name;
18451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol($$$)
18454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Deps) = @_;
18456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(link_symbol_internal($Symbol, $RunWith, \%Symbol_Library)) {
18457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Deps eq "+Deps")
18460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check the dependencies
1846162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(link_symbol_internal($Symbol, $RunWith, \%DepSymbol_Library)) {
18462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol_internal($$$)
18469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Where) = @_;
18471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Where or not $Symbol);
18472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Where->{$RunWith}{$Symbol})
18473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # the exact match by symbol name
18474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VSym = $SymVer{$RunWith}{$Symbol})
18477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # indirect symbol version, i.e.
18478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # foo_old and its symlink foo@v (or foo@@v)
184799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # foo_old may be in symtab table
18480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$VSym}) {
18481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
184841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Sym, $Spec, $Ver) = separate_symbol($Symbol);
18485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Sym and $Ver)
18486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for the symbol with the same version
18487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or without version
18488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym})
18489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo@v|foo@@v
18490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo
18491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@".$Ver})
18494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@@v
18495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@v
18496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@\@".$Ver})
18499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@v
18500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@@v
18501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
185071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols_App($)
18508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
185109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $Path);
18511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Imported = ();
185126fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "macos")
18513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1851407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
1851507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if(not $NM) {
1851607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1851807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        open(APP, "$NM -g \"$Path\" 2>\"$TMP_DIR/null\" |");
185199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
185209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
1852107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ U _([\w\$]+)\s*\Z/) {
18522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
185276fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    elsif($OStarget eq "windows")
18528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin.exe\"");
18532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18533a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$DumpBinCmd /IMPORTS \"$Path\" 2>\"$TMP_DIR/null\" |");
185349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
185359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
18536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\s*\w+\s+\w+\s+\w+\s+([\w\?\@]+)\s*/) {
18537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18548f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        open(APP, "$ReadelfCmd -Ws \"$Path\" 2>\"$TMP_DIR/null\" |");
185499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<APP>)
18551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
185529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $symtab)
185539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # do nothing with symtab
185549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($_, "'.dynsym'")!=-1)
185559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # dynamic table
185569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = undef;
185579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
18558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
185599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(index($_, "'.symtab'")!=-1)
185609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # symbol table
185619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $symtab = 1;
18562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
185639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(my @Info = readline_ELF($_))
18564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
185659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my ($Ndx, $Symbol) = ($Info[5], $Info[6]);
185669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
185679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # only imported symbols
185689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    push(@Imported, $Symbol);
18569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Imported;
18575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
185779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_BIND = map {$_=>1} (
185789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "WEAK",
185799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "GLOBAL"
185809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
185819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
185829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_TYPE = map {$_=>1} (
185839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "FUNC",
185849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "IFUNC",
185859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "OBJECT",
185869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COMMON"
185879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
185889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
185899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_VIS = map {$_=>1} (
185909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DEFAULT",
185919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PROTECTED"
185929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
185939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
18594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readline_ELF($)
185959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{ # read the line of 'readelf' output corresponding to the symbol
185969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my @Info = split(/\s+/, $_[0]);
185979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name
185989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
18599fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UND  av_image_fill_pointers@LIBAVUTIL_52 (3)
186009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # spaces
186019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # num
18602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18603fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Info==7)
18604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # UND SYMBOL (N)
18605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Info[7]=~/\(\d+\)/) {
18606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            pop(@Info);
18607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
186109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($#Info!=6)
186119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # other lines
186129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
186139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1861474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne "UND");
186159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_BIND{$Info[3]});
186169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_VIS{$Info[4]});
186179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info[5] eq "ABS" and $Info[0]=~/\A0+\Z/)
186189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3
186199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
186209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
186219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget eq "symbian")
186229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # _ZN12CCTTokenType4NewLE4TUid3RFs@@ctfinder{000a0000}[102020e5].dll
186239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Info[6], "_._.absent_export_")!=-1)
186249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # "_._.absent_export_111"@@libstdcpp{00010001}[10282872].dll
18625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
18626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
186279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[6]=~s/\@.+//g; # remove version
18628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
186299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($Info[2], "0x") == 0)
186309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # size == 0x3d158
186319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[2] = hex($Info[2]);
186329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
186339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return @Info;
18634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
186369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath($$)
186371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
186389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
186399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $LibVersion or not $Name);
186409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"get_LibPath"}{$LibVersion}{$Name}) {
186419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_LibPath"}{$LibVersion}{$Name};
186421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
186439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"get_LibPath"}{$LibVersion}{$Name} = get_LibPath_I($LibVersion, $Name));
186449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
186459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
186469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath_I($$)
186479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
186489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
186499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(is_abs($Name))
186501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
186519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Name)
186529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # absolute path
186539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return $Name;
186541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
186559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
186569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # broken
186579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return "";
186589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
186599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1866007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredObjects{$LibVersion}{$Name})
186619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1866207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredObjects{$LibVersion}{$Name};
186639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1866407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredSONAMEs{$LibVersion}{$Name})
186659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1866607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredSONAMEs{$LibVersion}{$Name};
186679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
186689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $DefaultPath = $DyLib_DefaultPath{$Name})
186699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # ldconfig default paths
186709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $DefaultPath;
186719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18672570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultLibPaths, @{$SystemPaths{"lib"}})
186739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # search in default linker directories
186749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and then in all system paths
186759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Dir."/".$Name) {
1867674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Dir,$Name);
186771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
186789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18679e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"}) {
18680e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
18681e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
186829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my @AllObjects = keys(%{$SystemObjects{$Name}})) {
186839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $AllObjects[0];
186849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
186859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $ShortName = parse_libname($Name, "name+ext", $OStarget))
186869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
186879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($ShortName ne $Name)
186881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # FIXME: check this case
186899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my $Path = get_LibPath($LibVersion, $ShortName)) {
186909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $Path;
186919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
186921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
186931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
186949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    # can't find
186959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "";
186961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
186971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
186989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub readSymbols_Lib($$$$$$)
18699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
187009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Lib_Path, $IsNeededLib, $Weak, $Deps, $Vers) = @_;
187019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $LibVersion or not $Lib_Path);
1870274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1870374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Real_Path = realpath($Lib_Path);
1870474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1870574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $Real_Path)
1870674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # broken link
1870774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return ();
1870874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1870974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1871074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Lib_Name = get_filename($Real_Path);
1871174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
18712fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ExtraInfo)
18713fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
1871474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $KnownLibs{$Real_Path} = 1;
18715fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $KnownLibs{$Lib_Path} = 1; # links
1871674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1871774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
187189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($IsNeededLib)
187199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
187209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CheckedDyLib{$LibVersion}{$Lib_Name}) {
187219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ();
187229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
187239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
187249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(isCyclical(\@RecurLib, $Lib_Name) or $#RecurLib>=1);
18725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CheckedDyLib{$LibVersion}{$Lib_Name} = 1;
1872662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
18727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurLib, $Lib_Name);
18728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Value_Interface, %Interface_Value, %NeededLib) = ();
1872957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    my $Lib_ShortName = parse_libname($Lib_Name, "name+ext", $OStarget);
1873057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko
1873157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(not $IsNeededLib)
1873257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    { # special cases: libstdc++ and libc
1873357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        if(my $ShortName = parse_libname($Lib_Name, "short", $OStarget))
1873457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        {
1873557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            if($ShortName eq "libstdc++")
1873657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libstdc++.so.6
1873757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $STDCXX_TESTING = 1;
1873857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
1873957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            elsif($ShortName eq "libc")
1874057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libc-2.11.3.so
1874157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $GLIBC_TESTING = 1;
1874257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
18743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18745dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $DebugPath = "";
18746a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug and not $DumpSystem)
187471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # debug mode
18748dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $DebugPath = $DEBUG_PATH{$LibVersion}."/libs/".get_filename($Lib_Path).".txt";
187491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mkpath(get_dirname($DebugPath));
187501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
18751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "macos")
18752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Mac OS X: *.dylib, *.a
1875307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
187544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(not $NM) {
187554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1875707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $NM .= " -g \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
18758a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
187591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
187601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
1876107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            system($NM." >\"$DebugPath\"");
187621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
187631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
187641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
187651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
1876607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            open(LIB, $NM." |");
187671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
18768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18770570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($CheckUndefined)
18771570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18772570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not $IsNeededLib)
18773570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18774570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(/ U _([\w\$]+)\s*\Z/)
18775570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
1877674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $UndefinedSymbols{$LibVersion}{$Lib_Name}{$1} = 0;
18777570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        next;
18778570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18779570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18780570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18781570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1878207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ [STD] _([\w\$]+)\s*\Z/)
18783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
18784570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $Symbol = $1;
1878562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1878662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1878757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1878862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
18789570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
18790570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
1879162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1879362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
18795570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
18796570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
187979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
187989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
18799570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
188009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
188019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
1880707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
188089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
188099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
188109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
188119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
1881207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1881307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                my $OtoolCmd = get_CmdPath("otool");
188144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                if(not $OtoolCmd) {
188154b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    exitStatus("Not_Found", "can't find \"otool\"");
1881607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1881707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
188189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$OtoolCmd -L \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
188199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
188209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
188219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([\/\\].+\.$LIB_EXT)\s*/
188229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
188239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
188249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
18825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
188269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
18827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OStarget eq "windows")
18831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Windows *.dll, *.lib
18832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
18835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
188361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DumpBinCmd .= " /EXPORTS \"".$Lib_Path."\" 2>$TMP_DIR/null";
18837a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
188381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
188391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
18840a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($DumpBinCmd." >\"$DebugPath\"");
188411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
188421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
188431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
188441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
188451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DumpBinCmd." |");
188461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
18847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 1197 4AC 0000A620 SetThreadStackGuarantee
18849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 1198 4AD          SetThreadToken (forwarded to ...)
18850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 3368 _o2i_ECPublicKey
1885154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko          # 1 0 00005B30 ??0?N = ... (with pdb)
1885254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(/\A\s*\d+\s+[a-f\d]+\s+[a-f\d]+\s+([\w\?\@]+)\s*(?:=.+)?\Z/i
18853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+[a-f\d]+\s+([\w\?\@]+)\s*\(\s*forwarded\s+/
1885454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            or /\A\s*\d+\s+_([\w\?\@]+)\s*(?:=.+)?\Z/)
18855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic, static and forwarded symbols
18856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $realname = $1;
1885762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1885862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1885957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1886062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
1886162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$realname} = $Lib_Name;
1886262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
1886362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1886562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
18867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$realname} = $Lib_Name;
18868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
188699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
188709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
188719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($realname, "_Z")==0 or index($realname, "?")==0) {
188729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
188739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
18879f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
188809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
188819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
188829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
188839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
188849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$DumpBinCmd /DEPENDENTS \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
188859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
188869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
188879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([^\s]+?\.$LIB_EXT)\s*/i
188889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
188899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{path_format($1, $OSgroup)} = 1;
188909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
18891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
188929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
18893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Unix; *.so, *.a
18898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Symbian: *.dso, *.lib
18899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18903f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Cmd = $ReadelfCmd." -Ws \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
18904a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
189051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
189061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
18907f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            system($Cmd." >\"$DebugPath\"");
189081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
189091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
189101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
189111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
18912f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
189131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
189149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
18916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
18918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic library specifics
189199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(defined $symtab)
1892062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
189219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(index($_, "'.dynsym'")!=-1)
1892262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # dynamic table
189239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $symtab = undef;
1892462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
189259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    # do nothing with symtab
189269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next;
18927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
189289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(index($_, "'.symtab'")!=-1)
18929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # symbol table
189309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = 1;
18931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
18932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
189349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))
18935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # read ELF entry
189369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
18937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # ignore interfaces that are imported from somewhere else
18938570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($CheckUndefined)
18939570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18940570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(not $IsNeededLib) {
1894174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            $UndefinedSymbols{$LibVersion}{$Lib_Name}{$Symbol} = 0;
18942570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18943570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
18945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18946c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                if($Bind eq "WEAK")
18947c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                {
1894807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $WeakSymbols{$LibVersion}{$Symbol} = 1;
18949c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    if($Weak eq "-Weak")
18950c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    { # skip WEAK symbols
18951c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                        next;
18952c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    }
18953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
189549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Short = $Symbol;
189559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Short=~s/\@.+//g;
189569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Type eq "OBJECT")
18957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # global data
18958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Symbol} = $Size;
18959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Short} = $Size;
18960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1896162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1896262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1896357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1896462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
189659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
189669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
1896762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
18968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1896962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
18970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
189719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
189729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
189739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($Vers)
189749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
189759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($LIB_EXT eq "so")
189769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # value
189779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Interface_Value{$LibVersion}{$Symbol} = $Value;
189789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Value_Interface{$LibVersion}{$Value}{$Symbol} = 1;
189799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
189819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
189829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
189839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
189849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
189859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
18986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
18987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18989f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
18990f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        close(LIB);
18991f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
18992f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Deps and $LIB_TYPE eq "dynamic")
18993f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        { # dynamic library specifics
18994f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Cmd = $ReadelfCmd." -Wd \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
18995f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
18996f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
18997f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            while(<LIB>)
18998f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
18999f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(/NEEDED.+\[([^\[\]]+)\]/)
19000f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # dependencies:
19001f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                  # 0x00000001 (NEEDED) Shared library: [libc.so.6]
19002f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $NeededLib{$1} = 1;
1900362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1900462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19005f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19006f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            close(LIB);
19007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
190099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Vers)
190109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib and $LIB_EXT eq "so")
190129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # get symbol versions
19013fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %Found = ();
19014fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19015fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # by value
1901674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
190189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
190199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Value = $Interface_Value{$LibVersion}{$Symbol})
19020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
190219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    foreach my $Symbol_SameValue (keys(%{$Value_Interface{$LibVersion}{$Value}}))
19022a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    {
190239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Symbol_SameValue ne $Symbol
190249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        and index($Symbol_SameValue,"\@")==-1)
190259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
190269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $SymVer{$LibVersion}{$Symbol_SameValue} = $Symbol;
19027fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $Found{$Symbol} = 1;
190289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            last;
190299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19030a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
19031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19032fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # default
19035fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19036fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19037fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@\@")==-1);
19039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@\@/
19041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # non-default
19049fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19050fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19052fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
19053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@([^\@]*)/
19055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19057fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
190639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Deps)
19064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
190659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $DyLib (sort keys(%NeededLib))
190669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Library_Needed{$LibVersion}{$Lib_Name}{get_filename($DyLib)} = 1;
19068fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1906974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(my $DepPath = get_LibPath($LibVersion, $DyLib))
1907074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1907174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(not $CheckedDyLib{$LibVersion}{get_filename($DepPath)}) {
1907274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    readSymbols_Lib($LibVersion, $DepPath, 1, "+Weak", $Deps, $Vers);
1907374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
190749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurLib);
19078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Library_Symbol{$LibVersion};
19079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
190819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes($)
19082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefixes = ();
190849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    get_prefixes_I([$_[0]], \%Prefixes);
190859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return keys(%Prefixes);
190869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
190879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
190889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes_I($$)
190899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
190909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $P (@{$_[0]})
19091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
190929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my @Parts = reverse(split(/[\/\\]+/, $P));
190939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Name = $Parts[0];
190949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach (1 .. $#Parts)
190959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
190969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $_[1]->{$Name}{$P} = 1;
190979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            last if($_>4 or $Parts[$_] eq "include");
190989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Name = $Parts[$_].$SLASH.$Name;
190999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19103e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenkosub checkSystemFiles()
19104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19105e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $Cache{"checkSystemFiles"} = 1;
19106e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SysHeaders = ();
19108e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19109e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"lib"}})
19110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -d $DevelPath);
19112e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
191132b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        my @Files = cmd_find($DevelPath,"f");
191142b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
191152b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        { # add symbolic links
191162b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            if(-f $Link) {
191172b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko                push(@Files, $Link);
191182b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko            }
191192b029aa551351dd379a6259e4700c225a80e5a98Andrey Ponomarenko        }
19120e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19121ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for headers in /usr/lib
19122ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        my @Headers = grep { /\.h(pp|xx)?\Z|\/include\// } @Files;
19123ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        @Headers = grep { not /\/(gcc|jvm|syslinux|kbd|parrot|xemacs|perl|llvm)/ } @Headers;
19124ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, @Headers);
19125e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19126e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        # search for libraries in /usr/lib (including symbolic links)
19127e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Libs = grep { /\.$LIB_EXT[0-9.]*\Z/ } @Files;
19128e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $Path (@Libs)
191299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19130e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            my $N = get_filename($Path);
19131e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{$N}{$Path} = 1;
19132e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{parse_libname($N, "name+ext", $OStarget)}{$Path} = 1;
19133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19135e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19136ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"include"}})
19137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19138ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        next if(not -d $DevelPath);
19139ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # search for all header files in the /usr/include
19140ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # with or without extension (ncurses.h, QtCore, ...)
19141ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        push(@SysHeaders, cmd_find($DevelPath,"f"));
19142ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        foreach my $Link (cmd_find($DevelPath,"l"))
19143ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        { # add symbolic links
19144ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if(-f $Link) {
19145ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                push(@SysHeaders, $Link);
19146e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            }
19147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19149ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    get_prefixes_I(\@SysHeaders, \%SystemHeaders);
19150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1915262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getSOPaths($)
19153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
191554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    my @Paths = ();
19156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Libs"}))
19157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Dest) {
19159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
19160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19161fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Dest = get_abs_path($Dest);
19162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @SoPaths_Dest = getSOPaths_Dest($Dest, $LibVersion);
19163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (@SoPaths_Dest) {
191644b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            push(@Paths, $_);
19165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    return sort @Paths;
19168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
191708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipLib($$)
19171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
19173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
191741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
191751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$Name}) {
19176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ShortName = parse_libname($Name, "name+ext", $OStarget);
19179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$ShortName}) {
19180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dir (keys(%{$SkipLibs{$LibVersion}{"Path"}}))
19183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Path=~/\Q$Dir\E([\/\\]|\Z)/) {
19185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipLibs{$LibVersion}{"Pattern"}}))
19189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
191901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Name=~/$P/) {
19191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
191931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($P=~/[\/\\]/ and $Path=~/$P/) {
19194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
192008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub specificHeader($$)
192018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
192028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Header, $Spec) = @_;
192038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Header);
192048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Spec eq "windows")
192068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {# MS Windows
192078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[._-])(win|wince|wnt)(\d\d|[._-]|\Z)/i);
192088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/([._-]w|win)(32|64)/i);
192098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(Win|Windows)[A-Z]/);
192108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(w|win|windows)(32|64|\.)/i);
192118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
192128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win32",
192138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win64",
192148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win",
192158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "windows",
192168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "msvcrt"
192178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        ); # /gsf-win32/
192188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
192198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Header=~/[\/\\](|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
192208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
192218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
192228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    elsif($Spec eq "macos")
192238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Mac OS
192248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[_-])mac[._-]/i);
192258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
192268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
192288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
192298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipAlienHeader($)
192318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
192328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
192338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Path);
192348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = get_dirname($Path);
192358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/2/)
192378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 2 - skip internal headers
192388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Terms = (
192398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "p",
192408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
192418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "int",
192428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
192438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "implementation",
192448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
192458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
192468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
192478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
192488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
192498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test",
192508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "gen"
192518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
192528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
192548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
192558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
192568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "port",
192578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
192588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
192598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "detail",
192608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "details",
192618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
192628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
192638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
192648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "config",
192658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compiler",
192668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "platform",
192678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test"
192688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
192698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $TERMs = join("|", @Terms)) {
192718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Name=~/(\A|[._-])($TERMs)([._-]|\Z)/i);
192728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
192738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
192748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Dir=~/(\A|[\/\\])(|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
192758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
192768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/[a-z](Imp|Impl|I|P)(\.|\Z)/);
192788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
192798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/1/)
192818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 1 - skip non-Linux headers
192828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "windows")
192838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
192848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "windows")) {
192858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
192868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
192878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
192888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "macos")
192898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
192908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "macos")) {
192918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
192928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
192938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
192948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
192958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
192968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # valid
192978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
192988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
192998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1930062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader($$)
1930162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1930262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1930362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
1930462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"skipHeader"}{$Path}) {
1930562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"skipHeader"}{$Path};
1930662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
193078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/1|2/)
193088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # --tolerant
193098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(skipAlienHeader($Path)) {
193108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return ($Cache{"skipHeader"}{$Path} = 1);
193118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
193128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
193138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$SkipHeaders{$LibVersion}})) {
193148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
193158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1931662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"skipHeader"}{$Path} = skipHeader_I(@_));
1931762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1931862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1931962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader_I($$)
19320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # returns:
19321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  1 - if header should NOT be included and checked
19322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  2 - if header should NOT be included, but should be checked
19323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
193241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
193251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(my $Kind = $SkipHeaders{$LibVersion}{"Name"}{$Name}) {
19326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Kind;
19327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19328f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $D (sort {$SkipHeaders{$LibVersion}{"Path"}{$a} cmp $SkipHeaders{$LibVersion}{"Path"}{$b}}
19329f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Path"}}))
19330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
193319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Path, $D)!=-1)
193329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
193339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Path=~/\Q$D\E([\/\\]|\Z)/) {
193349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $SkipHeaders{$LibVersion}{"Path"}{$D};
193359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19338f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $P (sort {$SkipHeaders{$LibVersion}{"Pattern"}{$a} cmp $SkipHeaders{$LibVersion}{"Pattern"}{$b}}
19339f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Pattern"}}))
19340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1934162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Kind = $SkipHeaders{$LibVersion}{"Pattern"}{$P})
1934262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1934362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Name=~/$P/) {
1934462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1934562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1934662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P=~/[\/\\]/ and $Path=~/$P/) {
1934762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1934862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
19352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
193559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject_Dir($$)
19356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $LibVersion) = @_;
19358570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep {$_ eq $Dir} @{$SystemPaths{"lib"}})
19359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # system directory
19360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($RegisteredObject_Dirs{$LibVersion}{$Dir})
19363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already registered
19364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (find_libs($Dir,"",1))
19367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
193698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if(skipLib($Path, $LibVersion));
193709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Path, $LibVersion);
19371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $RegisteredObject_Dirs{$LibVersion}{$Dir} = 1;
193739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
193749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
193759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject($$)
193769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
193779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1937854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
193799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Name = get_filename($Path);
1938007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    $RegisteredObjects{$LibVersion}{$Name} = $Path;
193816fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget=~/linux|bsd/i)
193822768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    {
193832768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        if(my $SONAME = getSONAME($Path)) {
193842768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko            $RegisteredSONAMEs{$LibVersion}{$SONAME} = $Path;
193852768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        }
193869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1938757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(my $Short = parse_libname($Name, "name+ext", $OStarget)) {
1938857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        $RegisteredObjects_Short{$LibVersion}{$Short} = $Path;
193899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1939054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19391b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(not $CheckedArch{$LibVersion} and -f $Path)
1939254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19393d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $ObjArch = getArch_Object($Path))
1939454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
19395d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            if($ObjArch ne getArch_GCC($LibVersion))
19396d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            { # translation unit dump generated by the GCC compiler should correspond to the input objects
19397d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $CheckedArch{$LibVersion} = 1;
19398d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey 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.");
1939954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1940054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1940154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1940254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko}
1940354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1940454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub getArch_Object($)
1940554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko{
1940654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $Path = $_[0];
1940754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1940854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my %MachineType = (
1940954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "14C" => "x86",
1941054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "8664" => "x86_64",
1941154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "1C0" => "arm",
1941254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        "200" => "ia64"
1941354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    );
1941454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19415b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    my %ArchName = (
19416b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:31-bit" => "s390",
19417b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "s390:64-bit" => "s390x",
19418b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common" => "ppc32",
19419b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "powerpc:common64" => "ppc64",
19420b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "i386:x86-64" => "x86_64",
19421b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "mips:3000" => "mips",
19422b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        "sparc:v8plus" => "sparcv9"
19423b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko    );
19424b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
194256fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    if($OStarget eq "windows")
1942654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1942754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $DumpbinCmd = get_CmdPath("dumpbin");
1942854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $DumpbinCmd) {
1942954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
1943054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1943154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1943254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $DumpbinCmd." /headers \"$Path\"";
1943354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Out = `$Cmd`;
1943454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1943554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/(\w+)\smachine/)
1943654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1943754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if(my $Type = $MachineType{uc($1)})
1943854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1943954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                return $Type;
1944054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1944154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1944254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
194436fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    elsif($OStarget=~/linux|bsd/)
1944454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1944554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $ObjdumpCmd = get_CmdPath("objdump");
1944654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if(not $ObjdumpCmd) {
1944754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"objdump\"");
1944854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1944954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1945054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        my $Cmd = $ObjdumpCmd." -f \"$Path\"";
194516fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko
194526fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        if($OSgroup eq "windows") {
194536fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "set LANG=$LOCALE & ".$Cmd;
194546fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
194556fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        else {
194566fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko            $Cmd = "LANG=$LOCALE ".$Cmd;
194576fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        }
194586fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko        my $Out = `$Cmd`;
1945954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1946054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Out=~/architecture:\s+([\w\-\:]+)/)
1946154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        {
1946254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $Arch = $1;
1946354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch=~s/\:(.+)//)
1946454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            {
1946554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                my $Suffix = $1;
1946654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19467b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                if(my $Name = $ArchName{$Arch.":".$Suffix})
1946854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                {
19469b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                    $Arch = $Name;
1947054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                }
1947154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1947254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19473b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch=~/i[3-6]86/) {
1947454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86";
1947554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1947654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1947754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($Arch eq "x86-64") {
1947854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko                $Arch = "x86_64";
1947954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1948054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19481b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            if($Arch eq "ia64-elf64") {
19482b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko                $Arch = "ia64";
19483b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko            }
19484b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko
19485d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            return $Arch;
1948654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1948754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1948854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    else
1948954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    { # macos, etc.
1949054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        # TODO
1949154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    }
1949254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1949354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    return undef;
194949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
194959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
194969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSONAME($)
194979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
194989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Path = $_[0];
194999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return if(not $Path);
195009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"getSONAME"}{$Path}) {
195019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"getSONAME"}{$Path};
195029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $ObjdumpCmd = get_CmdPath("objdump");
195049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $ObjdumpCmd) {
195059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"objdump\"");
195069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
19507a914cb546e74ff89ff5038d0a57d6e7032617d80Lénaïc Huard    my $SonameCmd = "$ObjdumpCmd -x \"$Path\" 2>$TMP_DIR/null";
195089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup eq "windows") {
195099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | find \"SONAME\"";
195109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else {
195129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | grep SONAME";
195139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1951454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $SonameInfo = `$SonameCmd`)
1951554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
195169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SonameInfo=~/SONAME\s+([^\s]+)/) {
195179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ($Cache{"getSONAME"}{$Path} = $1);
195189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
195199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
195209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"getSONAME"}{$Path}="");
19521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSOPaths_Dest($$)
19524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dest, $LibVersion) = @_;
195268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(skipLib($Dest, $LibVersion)) {
19527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Dest)
19530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not parse_libname($Dest, "name", $OStarget)) {
19532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "incorrect format of library (should be *.$LIB_EXT): \'$Dest\'");
19533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
195349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Dest, $LibVersion);
195359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject_Dir(get_dirname($Dest), $LibVersion);
19536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Dest);
19537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(-d $Dest)
19539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest=~s/[\/\\]+\Z//g;
1954162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Libs = ();
19542570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(grep { $Dest eq $_ } @{$SystemPaths{"lib"}})
19543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # you have specified /usr/lib as the search directory (<libs>) in the XML descriptor
19544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and the real name of the library by -l option (bz2, stdc++, Xaw, ...)
19545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"","*".esc($TargetLibraryName)."*.$LIB_EXT*",2))
19546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all files and symlinks that match the name of a library
19547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(get_filename($Path)=~/\A(|lib)\Q$TargetLibraryName\E[\d\-]*\.$LIB_EXT[\d\.]*\Z/i)
19548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
195499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    registerObject($Path, $LibVersion);
1955074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $Libs{realpath($Path)}=1;
19551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for all files and symlinks
19556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (find_libs($Dest,"",""))
19557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
195598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next if(skipLib($Path, $LibVersion));
195609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                registerObject($Path, $LibVersion);
1956174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Libs{realpath($Path)}=1;
19562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OSgroup eq "macos")
19564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # shared libraries on MacOS X may have no extension
19565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $Path (cmd_find($Dest,"f"))
19566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if(ignore_path($Path));
195688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next if(skipLib($Path, $LibVersion));
19569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(get_filename($Path)!~/\./
19570850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    and cmd_file($Path)=~/(shared|dynamic)\s+library/i)
19571850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
195729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        registerObject($Path, $LibVersion);
1957374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $Libs{realpath($Path)}=1;
19574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1957862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return keys(%Libs);
19579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
19581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
195851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isCyclical($$)
195861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
195871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Stack, $Value) = @_;
195881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return (grep {$_ eq $Value} @{$Stack});
19589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19591d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getGCC_Opts($)
19592d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19593d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19594d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19595d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my @Opts = ();
19596d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19597d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($CompilerOptions{$LibVersion})
19598d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # user-defined options
19599d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $CompilerOptions{$LibVersion});
19600d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19601d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GccOptions)
19602d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    { # additional
19603d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        push(@Opts, $GccOptions);
19604d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19605d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19606d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(@Opts) {
19607d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return join(" ", @Opts);
19608d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19609d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19610d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return undef;
19611d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19612d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19613b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenkosub getArch_GCC($)
19614d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{
19615d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $LibVersion = $_[0];
19616d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19617d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(defined $Cache{"getArch_GCC"}{$LibVersion}) {
19618d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        return $Cache{"getArch_GCC"}{$LibVersion};
19619d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19620d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19621d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Arch = undef;
19622d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19623d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
19624d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    {
19625d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        writeFile("$TMP_DIR/test.c", "int main(){return 0;}\n");
19626d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19627d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." test.c -o test";
19628d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
19629d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
19630d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
19631d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
19632d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19633d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
19634d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        system($Cmd);
19635d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
19636d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19637d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        $Arch = getArch_Object("$TMP_DIR/test");
19638d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19639d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test.c");
19640d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        unlink("$TMP_DIR/test");
19641d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19642d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19643d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Arch) {
19644d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check ARCH type");
19645d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19646d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19647d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return ($Cache{"getArch_GCC"}{$LibVersion} = $Arch);
19648d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko}
19649d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1965054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenkosub detectWordSize($)
19651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1965254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    my $LibVersion = $_[0];
1965354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19654d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    my $Size = undef;
19655d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19656d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    # speed up detection
1965754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    if(my $Arch = getArch($LibVersion))
1965854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
19659b862d1db5616ab2fabb7f983329ced73bef6a7d9Andrey Ponomarenko        if($Arch=~/\A(x86_64|s390x|ppc64|ia64|alpha)\Z/) {
19660d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "8";
19661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19662d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        elsif($Arch=~/\A(x86|s390|ppc32)\Z/) {
19663d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = "4";
19664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19666d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19667d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if($GCC_PATH)
1966854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko    {
1966954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        writeFile("$TMP_DIR/empty.h", "");
19670d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19671d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Cmd = $GCC_PATH." -E -dD empty.h";
19672d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        if(my $Opts = getGCC_Opts($LibVersion))
19673d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        { # user-defined options
19674d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Cmd .= " ".$Opts;
19675d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        }
19676d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19677d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($TMP_DIR);
19678d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        my $Defines = `$Cmd`;
19679d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        chdir($ORIG_DIR);
19680d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
1968154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        unlink("$TMP_DIR/empty.h");
1968254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
1968354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/)
1968454040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 4
19685d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko            $Size = $1;
1968654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
1968754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/)
1968854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        { # GCC 3
1968954040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            my $PTRDIFF = $1;
1969054040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            if($PTRDIFF=~/long/) {
19691d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "8";
1969254040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1969354040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            else {
19694d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko                $Size = "4";
1969554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko            }
1969654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        }
19697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1969854040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
19699d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    if(not $Size) {
19700d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko        exitStatus("Error", "can't check WORD size");
19701d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    }
19702d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko
19703d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko    return $Size;
19704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19706d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenkosub getWordSize($)
19707d2ed4c6fe9e08b31b17b1a93054396d40f5dc9efAndrey Ponomarenko{ # to use in module
19708f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return $WORD_SIZE{$_[0]};
19709f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
19710f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
19711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub majorVersion($)
19712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V = $_[0];
19714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $V);
19715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VParts = split(/\./, $V);
19716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VParts[0];
19717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVersions($$)
197201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # compare two versions in dotted-numeric format
19721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($V1, $V2) = @_;
19722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if($V1 eq $V2);
19723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V1Parts = split(/\./, $V1);
19724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V2Parts = split(/\./, $V2);
19725570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
19726570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
19727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
19728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
19729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return -1 if($#V1Parts < $#V2Parts);
19731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#V1Parts > $#V2Parts);
19732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_ABI_Dump($$)
19736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
19738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
19739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FilePath = "";
197409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(isDump_U($Path))
19741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi
19742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = $Path;
19743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi.tar.gz
19746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = unpackDump($Path);
197479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not isDump_U($FilePath)) {
197489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
197499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19751850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1975201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ABI = {};
19753850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1975401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Line = readLineNum($FilePath, 0);
1975501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Line=~/xml/)
1975601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # XML format
1975701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        loadModule("XmlDump");
1975801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = readXmlDump($FilePath);
19759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1976001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    else
1976101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # Perl Data::Dumper format (default)
1976201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        open(DUMP, $FilePath);
1976301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        local $/ = undef;
1976401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $Content = <DUMP>;
1976501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        close(DUMP);
1976601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1976701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(get_dirname($FilePath) eq $TMP_DIR."/unpack")
1976801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # remove temp file
1976901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            unlink($FilePath);
1977001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1977101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Content!~/};\s*\Z/) {
1977201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
1977301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1977401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = eval($Content);
1977501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $ABI) {
1977601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
1977701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
19778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # new dumps (>=1.22) have a personal versioning
19780570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $DVersion = $ABI->{"ABI_DUMP_VERSION"};
1978101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ToolVersion = $ABI->{"ABI_COMPLIANCE_CHECKER_VERSION"};
19782570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $DVersion)
19783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old dumps (<=1.21.6) have been marked by the tool version
19784570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $DVersion = $ToolVersion;
19785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19786570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $UsedDump{$LibVersion}{"V"} = $DVersion;
1978752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    $UsedDump{$LibVersion}{"M"} = $ABI->{"LibraryName"};
19788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ABI->{"ABI_DUMP_VERSION"})
19790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
19791570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(cmpVersions($DVersion, $ABI_DUMP_VERSION)>0)
19792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19793570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $ABI_DUMP_VERSION)");
19794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19795fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19796fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
19797fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19798fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(cmpVersions($DVersion, $TOOL_VERSION)>0)
19799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19800570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $TOOL_VERSION)");
19801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19802fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
198036ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko
19804fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(majorVersion($DVersion)<2)
198056ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
198066ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko        exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (allowed only 2.0<=V<=$ABI_DUMP_VERSION)");
19807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"ABI_DUMPER_VERSION"})
19810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # DWARF ABI Dump
19811fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"P"} = 1;
19812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"R"} = 0; # not implemented yet
19813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UsedDump{$LibVersion}{"DWARF"} = 1;
19815fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19816fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TargetComponent = "module";
19817fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19818fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
198195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.11"))
198205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # old ABI dumps
198215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
198221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1982301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    elsif($ABI->{"BinOnly"})
198241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # ABI dump created with --binary option
198251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
198261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
198275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
198285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # default
198295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"SrcBin"} = 1;
198305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
19831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1983201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $ABI->{"Mode"}
1983301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    and $ABI->{"Mode"} eq "Extended")
19834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
19835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ExtendedCheck = 1;
19836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1983774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ABI->{"Extra"}) {
1983874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ExtraDump = 1;
1983974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1984074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1984101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Lang = $ABI->{"Language"})
19842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UsedDump{$LibVersion}{"L"} = $Lang;
19844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        setLanguage($LibVersion, $Lang);
19845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1984662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
1984701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeInfo{$LibVersion} = $ABI->{"TypeInfo"};
1984862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1984962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
19850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
1985101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $TInfo = $ABI->{"TypeInfo"};
1985262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TInfo)
1985362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for older ABI dumps
1985401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TInfo = $ABI->{"TypeDescr"};
1985562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1985662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Tid_TDid = ();
1985762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TDid (keys(%{$TInfo}))
1985862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1985962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TInfo->{$TDid}}))
1986062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1986162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $Tid if($Tid>$MAX_ID);
1986262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $TDid if($TDid and $TDid>$MAX_ID);
19863177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Tid_TDid{$Tid}{$TDid} = 1;
1986462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1986562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1986662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %NewID = ();
1986762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%Tid_TDid))
1986862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1986962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @TDids = keys(%{$Tid_TDid{$Tid}});
1987062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($#TDids>=1)
1987162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1987262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $TDid (@TDids)
1987362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1987462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TDid) {
1987562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
1987662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
1987762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
1987862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
19879177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $ID = ++$MAX_ID;
19880177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
19881177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $NewID{$TDid}{$Tid} = $ID;
19882177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$ID}} = %{$TInfo->{$TDid}{$Tid}};
19883177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeInfo{$LibVersion}{$ID}{"Tid"} = $ID;
1988462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
1988562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1988662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1988762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
1988862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1988962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TDid = $TDids[0];
1989062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
1989162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1989262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1989362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
1989462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1989562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Info = %{$TypeInfo{$LibVersion}{$Tid}};
1989662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $Info{"BaseType"})
1989762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1989862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Bid = $Info{"BaseType"}{"Tid"};
1989962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BDid = $Info{"BaseType"}{"TDid"};
1990062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $BDid="" if(not defined $BDid);
19901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{"BaseType"}{"TDid"});
1990262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(defined $NewID{$BDid} and my $ID = $NewID{$BDid}{$Bid}) {
19903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$Tid}{"BaseType"} = $ID;
1990462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1990562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1990662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TDid"});
1990762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
19908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1990901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Machine_DumpInfo($ABI, $LibVersion);
1991001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymbolInfo{$LibVersion} = $ABI->{"SymbolInfo"};
19911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion})
19912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1991301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$LibVersion} = $ABI->{"FuncDescr"};
19914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
19916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validation of old-version dumps
19917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck) {
19918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Invalid_Dump", "the input dump d$LibVersion is invalid");
19919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1992162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
1992201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $DepLibrary_Symbol{$LibVersion} = $ABI->{"DepSymbols"};
19923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1992462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
1992562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
1992601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $DepSymbols = $ABI->{"DepSymbols"};
1992762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols) {
1992801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $DepSymbols = $ABI->{"DepInterfaces"};
1992962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1993062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols)
1993162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # Cannot reconstruct DepSymbols. This may result in false
1993262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # positives if the old dump is for library 2. Not a problem if
1993362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # old dumps are only from old libraries.
1993462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbols = {};
1993562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1993662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepSymbols})) {
1993762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = 1;
1993862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
19939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1994001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymVer{$LibVersion} = $ABI->{"SymbolVersion"};
19941d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
19942d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    if(my $V = $TargetVersion{$LibVersion}) {
19943d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $V;
19944d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
19945d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    else {
19946d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $ABI->{"LibraryVersion"};
19947d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko    }
19948d59580888a06555261f3d4255d9c2cfcb408a51aAndrey Ponomarenko
1994901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipTypes{$LibVersion} = $ABI->{"SkipTypes"};
19950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipTypes{$LibVersion})
19951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
1995201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipTypes{$LibVersion} = $ABI->{"OpaqueTypes"};
19953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19954ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
19955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
19956ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -skip-symbols option
19957ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"SkipSymbols"};
19958ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $SkipSymbols{$LibVersion})
19959ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
19960ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"SkipInterfaces"};
19961ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
19962ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        if(not $SkipSymbols{$LibVersion})
19963ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        { # support for old dumps
19964ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko            $SkipSymbols{$LibVersion} = $ABI->{"InternalInterfaces"};
19965ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        }
19966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1996701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipNameSpaces{$LibVersion} = $ABI->{"SkipNameSpaces"};
19968ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
19969ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if(not $TargetHeaders{$LibVersion})
19970ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    { # if not defined by -headers-list option
19971ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko        $TargetHeaders{$LibVersion} = $ABI->{"TargetHeaders"};
19972ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    }
19973ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko
1997401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Path (keys(%{$ABI->{"SkipHeaders"}}))
19975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1997601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = $ABI->{"SkipHeaders"}{$Path};
19977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
1997801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = $ABI->{"SkipHeaders"}{$Path};
19979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    read_Source_DumpInfo($ABI, $LibVersion);
1998101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Libs_DumpInfo($ABI, $LibVersion);
199825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.10.1")
199835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    or not $TargetHeaders{$LibVersion})
19984850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # support for old ABI dumps: added target headers
19985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
199863e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
19987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19988fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
199893e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
19990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
19991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1999201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Constants{$LibVersion} = $ABI->{"Constants"};
19993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"GccConstants"})
19994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # 3.0
19995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Name (keys(%{$ABI->{"GccConstants"}})) {
19996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Constants{$LibVersion}{$Name}{"Value"} = $ABI->{"GccConstants"}{$Name};
19997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
19998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2000001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $NestedNameSpaces{$LibVersion} = $ABI->{"NameSpaces"};
20001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $NestedNameSpaces{$LibVersion})
20002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
20003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Cannot reconstruct NameSpaces. This may affect design
20004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # of the compatibility report.
20005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $NestedNameSpaces{$LibVersion} = {};
20006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # target system type
20008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # needed to adopt HTML report
20009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DumpSystem)
20010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # to use in createSymbolsList(...)
2001101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $OStarget = $ABI->{"Target"};
20012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # recreate environment
20014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$Library_Symbol{$LibVersion}}))
20015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2001662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
20017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2001862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2001962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol}<=-1)
20020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # data marked as -size in the dump
20021fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $GlobalDataObject{$LibVersion}{$Symbol} = -$Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol};
20022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
200239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($COMMON_LANGUAGE{$LibVersion} ne "C++")
200249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
200259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
200269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    setLanguage($LibVersion, "C++");
200279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
20028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2003162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$DepLibrary_Symbol{$LibVersion}}))
2003262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2003362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepLibrary_Symbol{$LibVersion}{$Lib_Name}})) {
2003462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2003562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2003662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2003762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VFunc = ();
200391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20041f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
2004262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2004362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Symbol_Library{$LibVersion}{$MnglName}
2004462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $DepSymbol_Library{$LibVersion}{$MnglName}) {
2004562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@VFunc, $MnglName);
2004662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
20047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(@VFunc, $LibVersion);
20050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2005162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
2005262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not checkDump($LibVersion, "3.0"))
20054fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
20057fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseType = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
20058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
20059fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(ref($BaseType) eq "HASH") {
20060fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"}{"Tid"};
20061fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
20062fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
20063fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20064fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20065fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not checkDump($LibVersion, "3.2"))
20067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # support for old ABI dumps
20068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"})
20071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Offset (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"VTable"}})) {
20073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset} = simplifyVTable($TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset});
20074177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
20075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20078177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # repair target headers list
20079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TargetHeaders{$LibVersion});
20080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
200813e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
200823e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        }
200833e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
200843e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20085177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20087177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # non-target constants from anon enums
20088177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Name (keys(%{$Constants{$LibVersion}}))
20089177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20090177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $ExtraDump
20091177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not is_target_header($Constants{$LibVersion}{$Name}{"Header"}, $LibVersion))
20092177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20093177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($Constants{$LibVersion}{$Name});
20094177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20095177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20096177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
20097177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2009874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not checkDump($LibVersion, "2.20"))
2009974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # support for old ABI dumps
2010074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2010174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2010274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2010374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2010474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum|Typedef/)
2010574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # repair complex types first
2010674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                next;
2010774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2010874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
20109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseId = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
2011074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
2011174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $BType = lc($TypeInfo{$LibVersion}{$BaseId}{"Type"});
2011274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($BType=~/Struct|Union|Enum/i)
2011374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2011474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"};
2011574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Name"}=~s/\A\Q$BName\E\b/$BType $BName/g;
2011674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
2011774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2011874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2011974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2012074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2012174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2012274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
2012374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum/) {
2012474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Name"} = lc($TType)." ".$TName;
2012574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2012674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2012774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2012874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2012962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20130f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    { # order is important
2013162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"})
2013262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for old ABI dumps < 2.0 (ACC 1.22)
2013362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $BId (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}}))
2013462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2013562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Access = $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}{$BId})
20136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2013762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Access ne "public") {
2013862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId}{"access"} = $Access;
20139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
20140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2014162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId} = {};
2014262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2014362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseClass"});
2014462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
201459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $TypeInfo{$LibVersion}{$TypeId}{"Header"})
201469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
201479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = path_format($Header, $OSgroup);
201489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20149fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $TypeInfo{$LibVersion}{$TypeId}{"Source"})
20150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20151fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = $Source;
20152fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
2015301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not defined $TypeInfo{$LibVersion}{$TypeId}{"Tid"}) {
2015401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Tid"} = $TypeId;
2015501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2015662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %TInfo = %{$TypeInfo{$LibVersion}{$TypeId}};
2015762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TInfo{"Base"})
2015862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2015962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach (keys(%{$TInfo{"Base"}})) {
2016062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Class_SubClasses{$LibVersion}{$_}{$TypeId}=1;
2016162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2016262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2016301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($TInfo{"Type"} eq "MethodPtr")
2016401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
2016501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(defined $TInfo{"Param"})
2016601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # support for old ABI dumps <= 1.17
2016701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(not defined $TInfo{"Param"}{"0"})
2016801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                {
2016901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Max = keys(%{$TInfo{"Param"}});
2017001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    foreach my $Pos (1 .. $Max) {
2017101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TInfo{"Param"}{$Pos-1} = $TInfo{"Param"}{$Pos};
2017201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2017301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    delete($TInfo{"Param"}{$Max});
2017401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$TypeId}} = %TInfo;
2017501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2017601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2017701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"BaseType"} eq $TypeId)
20179fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # fix ABI dump
20180fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseType"});
20181fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20182fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"Type"} eq "Typedef" and not $TInfo{"Artificial"})
2018362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
20184fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BTid = $TInfo{"BaseType"})
2018562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2018662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BName = $TypeInfo{$LibVersion}{$BTid}{"Name"};
2018762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $BName)
2018862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # broken type
2018962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2019062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2019162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TInfo{"Name"} eq $BName)
2019262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # typedef to "class Class"
201938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                  # should not be registered in TName_Tid
2019462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2019562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2019662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}}) {
2019762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}} = $BName;
2019862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
20199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2020062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2020162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TName_Tid{$LibVersion}{$TInfo{"Name"}})
2020262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # classes: class (id1), typedef (artificial, id2 > id1)
20203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TName_Tid{$LibVersion}{formatName($TInfo{"Name"}, "T")} = $TypeId;
2020462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2020562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2020662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2020762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.15"))
2020862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2020962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Dups = ();
2021062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
2021162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2021262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
20213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2021462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not defined $TypeInfo{$LibVersion}{$ClassId})
2021562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # remove template decls
2021662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    delete($SymbolInfo{$LibVersion}{$InfoId});
2021762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
20218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20220b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $MName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
20221b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not $MName and $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
2022262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
2022362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($SymbolInfo{$LibVersion}{$InfoId});
20224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20228f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20229f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
20230ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if(my $Class = $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
20231ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Static"}
20232ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
20233ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # support for old ABI dumps (< 3.1)
20234ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if(not defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
20235ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            or $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
20236ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            { # add "this" first parameter
20237ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $ThisTid = getTypeIdByName($TypeInfo{$LibVersion}{$Class}{"Name"}."*const", $LibVersion);
20238ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my %PInfo = ("name"=>"this", "type"=>"$ThisTid");
20239ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20240ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
20241ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                {
20242ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    my @Pos = sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
20243ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    foreach my $Pos (reverse(0 .. $#Pos)) {
20244ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos+1}} = %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos}};
20245ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    }
20246ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                }
20247ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{"0"} = \%PInfo;
20248ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            }
20249ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
20250ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20251f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(not $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
20252f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # ABI dumps have no mangled names for C-functions
20253f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
20254f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
202559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $SymbolInfo{$LibVersion}{$InfoId}{"Header"})
202569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
202579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = path_format($Header, $OSgroup);
202589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20259fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $SymbolInfo{$LibVersion}{$InfoId}{"Source"})
20260fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20261fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = $Source;
20262fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20263f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
20264f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Dump"} = 1;
20266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Machine_DumpInfo($$)
20269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2027001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
2027101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"Arch"}) {
2027201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $CPU_ARCH{$LibVersion} = $ABI->{"Arch"};
20273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2027401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"WordSize"}) {
2027501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"WordSize"};
20276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2027901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"SizeOfPointer"};
20280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $WORD_SIZE{$LibVersion})
20282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps (<1.23)
20283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Tid = getTypeIdByName("char*", $LibVersion))
20284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # size of char*
2028562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WORD_SIZE{$LibVersion} = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PSize = 0;
2029062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
20291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2029262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeInfo{$LibVersion}{$Tid}{"Type"} eq "Pointer")
2029362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # any "pointer"-type
2029462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $PSize = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
20296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($PSize)
20299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # a pointer type size
20300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $WORD_SIZE{$LibVersion} = $PSize;
20301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("WARNING", "cannot identify a WORD size in the ABI dump (too old format)");
20304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2030701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"GccVersion"}) {
2030801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $GCC_VERSION{$LibVersion} = $ABI->{"GccVersion"};
20309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Libs_DumpInfo($$)
20313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2031401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
203159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $Library_Symbol{$LibVersion} = $ABI->{"Symbols"};
203169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $Library_Symbol{$LibVersion})
203179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # support for old dumps
203189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Library_Symbol{$LibVersion} = $ABI->{"Interfaces"};
203199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
20320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Library_Symbol{$LibVersion}})
20321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Libs"} = "OK";
20323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20326fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub read_Source_DumpInfo($$)
20327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2032801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
20329fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2033001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%{$ABI->{"Headers"}})
20331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Headers"} = "OK";
20333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2033401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Identity (sort {$ABI->{"Headers"}{$a}<=>$ABI->{"Headers"}{$b}} keys(%{$ABI->{"Headers"}}))
203356ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Identity"} = $Identity;
2033701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Pos"} = $ABI->{"Headers"}{$Identity};
20338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20339fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20340fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(keys(%{$ABI->{"Sources"}})
20341fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not $DumpAPI) {
20342fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{$LibVersion}{"Sources"} = "OK";
20343fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20344fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (sort {$ABI->{"Sources"}{$a}<=>$ABI->{"Sources"}{$b}} keys(%{$ABI->{"Sources"}}))
203456ed91e7e3638a38533dcceda69075ae1d641770eAndrey Ponomarenko    {
20346fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Identity"} = $Name;
20347fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Pos"} = $ABI->{"Headers"}{$Name};
20348fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_libs($$$)
20352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Type, $MaxDepth) = @_;
20354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # FIXME: correct the search pattern
203558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return cmd_find($Path, $Type, '\.'.$LIB_EXT.'[0-9.]*\Z', $MaxDepth, 1);
20356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createDescriptor($$)
20359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $LibVersion or not $Path
20362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -e $Path) {
20363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
20364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-d $Path)
20366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory with headers files and shared objects
20367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "
20368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <version>
20369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ".$TargetVersion{$LibVersion}."
20370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </version>
20371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <headers>
20373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </headers>
20375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <libs>
20377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </libs>";
20379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # files
203829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Path=~/\.(xml|desc)\Z/i)
20383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(is_header($Path, 2, $LibVersion))
20387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # header file
20388ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            $CheckHeadersOnly = 1;
20389ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20390ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==1) {
20391ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "X";
20392ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20393ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20394ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($LibVersion==2) {
20395ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $TargetVersion{$LibVersion} = "Y";
20396ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            }
20397ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lib_default_paths()
20419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LPaths = ();
20421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "bsd")
20422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20423a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20424a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
20425a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -r 2>\"$TMP_DIR/null\"`))
20426a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
2042774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/\A[ \t]*\d+:\-l(.+) \=\> (.+)\Z/)
2042874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2042974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $Name = "lib".$1;
2043074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name}) {
2043174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $2;
2043274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
20437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $OSgroup eq "linux")
20445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # use host (x86) ldconfig with the target (arm) ld.so.conf
20446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-e $SystemRoot."/etc/ld.so.conf") {
20447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LdConfig .= " -f ".$SystemRoot."/etc/ld.so.conf";
20448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20450a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -p 2>\"$TMP_DIR/null\"`))
20451a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
20452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A[ \t]*([^ \t]+) .* \=\> (.+)\Z/)
20453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Name, $Path) = ($1, $2);
20455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path=~s/[\/]{2,}/\//;
2045674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name})
2045774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    { # get first element from the list of available paths
2045874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2045974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2046074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib/i386-linux-gnu/libstdc++.so.6
2046174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
2046274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2046374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $Path;
2046474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2046882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko        elsif($OSgroup eq "linux") {
20469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%LPaths;
20473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_bin_default_paths()
20476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $EnvPaths = $ENV{"PATH"};
20478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos") {
20479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $EnvPaths.=":".$ENV{"BETOOLS"};
20480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Sep = ($OSgroup eq "windows")?";":":|;";
20482570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (split(/$Sep/, $EnvPaths))
20483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
20485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Path);
20486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot
20487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\A\Q$SystemRoot\E\//)
20488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT use binaries from target system
20489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20491570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U(\@DefaultBinPaths, $Path);
20492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_inc_default_paths()
20496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20497570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %DPaths = ("Cpp"=>[],"Gcc"=>[],"Inc"=>[]);
20498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
20499a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $Line (split(/\n/, `$GCC_PATH -v -x c++ -E \"$TMP_DIR/empty.h\" 2>&1`))
205001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting GCC default include paths
20501570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        next if(index($Line, "/cc1plus ")!=-1);
20502570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~/\A[ \t]*((\/|\w+:\\).+)[ \t]*\Z/)
20504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2050574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Path = realpath($1);
20506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = path_format($Path, $OSgroup);
20507570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Path, "c++")!=-1
20508570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            or index($Path, "/g++/")!=-1)
20509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Cpp"}, $Path);
20511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $MAIN_CPP_DIR
20512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or get_depth($MAIN_CPP_DIR)>get_depth($Path)) {
20513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MAIN_CPP_DIR = $Path;
20514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            elsif(index($Path, "gcc")!=-1) {
20517570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Gcc"}, $Path);
20518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Path=~/local[\/\\]+include/)
20522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # local paths
20523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    next;
20524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $Path!~/\A\Q$SystemRoot\E(\/|\Z)/)
20527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # The GCC include path for user headers is not a part of the system root
20528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # The reason: you are not specified the --cross-gcc option or selected a wrong compiler
20529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # or it is the internal cross-GCC path like arm-linux-gnueabi/include
20530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Inc"}, $Path);
20533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
20537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %DPaths;
20538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_default_paths($)
20541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($HSearch, $LSearch, $BSearch, $GSearch) = (1, 1, 1, 1);
20543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Search = $_[0];
20544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/inc/) {
20545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/lib/) {
20548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/bin/) {
20551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $BSearch = 0;
20552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/gcc/) {
20554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GSearch = 0;
20555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"include"}})
20557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"lib"}})
205626fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko    { # <search_libs> section of the XML descriptor
205636fce0fa11412bd4f0f5e6d5ccf6cd42c4f4342c7Andrey Ponomarenko      # do NOT search for systems libraries
20564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (keys(%{$OS_AddPath{$OSgroup}}))
20567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # additional search paths
20568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "include" and not $HSearch);
20569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "lib" and not $LSearch);
20570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "bin" and not $BSearch);
20571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{$Type}, grep { -d $_ } @{$OS_AddPath{$OSgroup}{$Type}});
20572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
20574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unix-like
20575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Type ("include", "lib", "bin")
20576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # automatic detection of system "devel" directories
20577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "include" and not $HSearch);
20578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "lib" and not $LSearch);
20579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "bin" and not $BSearch);
20580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($UsrDir, $RootDir) = ("/usr", "/");
20581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $Type ne "bin")
20582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 1. search for target headers and libraries
20583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # 2. use host commands: ldconfig, readelf, etc.
20584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($UsrDir, $RootDir) = ("$SystemRoot/usr", $SystemRoot);
20585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20586570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U($SystemPaths{$Type}, cmd_find($RootDir,"d","*$Type*",1));
20587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-d $RootDir."/".$Type)
20588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if "/lib" is symbolic link
20589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($RootDir eq "/") {
20590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, "/".$Type);
20591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
20593570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $RootDir."/".$Type);
20594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20596570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(-d $UsrDir)
20597570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
20598570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{$Type}, cmd_find($UsrDir,"d","*$Type*",1));
20599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-d $UsrDir."/".$Type)
20600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # if "/usr/lib" is symbolic link
20601570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $UsrDir."/".$Type);
20602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_bin_default_paths();
20609570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, @DefaultBinPaths);
20610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check environment variables
20612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos")
20613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
206144b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        foreach (my @Paths = @{$SystemPaths{"bin"}})
20615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
206164b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($_ eq ".") {
206174b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                next;
206184b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
206194b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            # search for /boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-101111/bin/
206204b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my @Dirs = sort cmd_find($_, "d", "bin")) {
206214b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                push_U($SystemPaths{"bin"}, sort {get_depth($a)<=>get_depth($b)} @Dirs);
20622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HSearch)
20625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20626570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultIncPaths, grep { is_abs($_) } (
20627570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BEINCLUDES"})
20628570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LSearch)
20631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20632570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, grep { is_abs($_) } (
20633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BELIBRARIES"}),
20634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"LIBRARY_PATH"})
20635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LSearch)
20639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # using linker to get system paths
20640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LPaths = detect_lib_default_paths())
20641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # unix-like
20642570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Dirs = ();
20643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Name (keys(%{$LPaths}))
20644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $LPaths->{$Name}!~/\A\Q$SystemRoot\E\//)
20647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # wrong ldconfig configuration
20648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # check your <sysroot>/etc/ld.so.conf
20649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DyLib_DefaultPath{$Name} = $LPaths->{$Name};
20652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Dir = get_dirname($LPaths->{$Name})) {
20653570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Dirs{$Dir} = 1;
20654570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20656570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, sort {get_depth($a)<=>get_depth($b)} sort keys(%Dirs));
20657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, @DefaultLibPaths);
20659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc)
20663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --cross-gcc=arm-linux-gcc
20664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-e $CrossGcc)
20665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # absolute or relative path
20666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = get_abs_path($CrossGcc);
20667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($CrossGcc!~/\// and get_CmdPath($CrossGcc))
20669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # command name
20670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = $CrossGcc;
20671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$CrossGcc\'");
20674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GCC_PATH=~/\s/) {
20676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = "\"".$GCC_PATH."\"";
20677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GSearch)
20681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC path and default include dirs
20682570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CrossGcc)
20683570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # try default gcc
20684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $GCC_PATH = get_CmdPath("gcc");
20685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2068601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $GCC_PATH)
2068701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to find gcc-X.Y
20688570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (@{$SystemPaths{"bin"}})
2068901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
206908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my @GCCs = cmd_find($Path, "", '/gcc-[0-9.]*\Z', 1, 1))
2069101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                { # select the latest version
2069201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    @GCCs = sort {$b cmp $a} @GCCs;
2069301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    if(check_gcc($GCCs[0], "3"))
2069401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    {
2069501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $GCC_PATH = $GCCs[0];
2069601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        last;
2069701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2069801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2069901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2070001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GCC_PATH) {
20702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find GCC>=3.0 in PATH");
20703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20704f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
20705ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(my $GCC_Ver = get_dumpversion($GCC_PATH))
20706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20707ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my $GccTarget = get_dumpmachine($GCC_PATH);
20708ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20709ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GccTarget=~/linux/)
20710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20711ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "linux";
20712ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
20713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20714ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            elsif($GccTarget=~/symbian/)
20715ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            {
20716ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $OStarget = "symbian";
20717ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
20718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20719ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20720ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget, target: ".getArch_GCC(1).")");
20721ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20722ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            # check GCC version
20723ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            if($GCC_Ver=~/\A4\.8(|\.[012])\Z/)
20724ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            { # bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57850
20725ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                # introduced in 4.8
20726ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                # fixed in 4.8.3
20727ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                printMsg("WARNING", "Not working properly with GCC $GCC_Ver. Please update or downgrade GCC or use a local installation by --gcc-path=PATH option.");
20728ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko                $EMERGENCY_MODE_48 = 1;
20729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20731ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        else {
20732ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "something is going wrong with the GCC compiler");
20733ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
20734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HSearch)
20736ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    {
20737ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # GCC standard paths
20738ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if($GCC_PATH and not $NoStdInc)
20739ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        {
20740ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            my %DPaths = detect_inc_default_paths();
20741ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultCppPaths = @{$DPaths{"Cpp"}};
20742ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultGccPaths = @{$DPaths{"Gcc"}};
20743ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            @DefaultIncPaths = @{$DPaths{"Inc"}};
20744ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            push_U($SystemPaths{"include"}, @DefaultIncPaths);
20745ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        }
20746ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
20747ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        # users include paths
20748dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $IncPath = "/usr/include";
20749dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($SystemRoot) {
20750dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $IncPath = $SystemRoot.$IncPath;
20751dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
20752dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(-d $IncPath) {
20753570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@UsersIncPath, $IncPath);
20754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2075674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2075774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
2075874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
2075974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-libs", join("\n", @DefaultLibPaths));
2076074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-includes", join("\n", (@DefaultCppPaths, @DefaultGccPaths, @DefaultIncPaths)));
2076174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
20762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLIB_EXT($)
20765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_LibExt{$LIB_TYPE}{$Target}) {
20768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_LibExt{$LIB_TYPE}{"default"};
20771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAR_EXT($)
20774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_Archive{$Target}) {
20777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_Archive{"default"};
20780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpversion($)
20783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpversion"}{$Cmd}) {
20787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpversion"}{$Cmd};
20788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20789a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $V = `$Cmd -dumpversion 2>\"$TMP_DIR/null\"`;
20790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($V);
20791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpversion"}{$Cmd} = $V);
20792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpmachine($)
20795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpmachine"}{$Cmd}) {
20799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpmachine"}{$Cmd};
20800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20801a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Machine = `$Cmd -dumpmachine 2>\"$TMP_DIR/null\"`;
20802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($Machine);
20803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpmachine"}{$Cmd} = $Machine);
20804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20806570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub checkCmd($)
20807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Options = (
20811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "--version",
20812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "-help"
20813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
20814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Opt (@Options)
20815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20816a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my $Info = `$Cmd $Opt 2>\"$TMP_DIR/null\"`;
20817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Info) {
20818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
20819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
20822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2082462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub check_gcc($$)
20825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2082662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Cmd, $ReqVer) = @_;
2082762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $Cmd or not $ReqVer);
2082862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"check_gcc"}{$Cmd}{$ReqVer}) {
2082962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"check_gcc"}{$Cmd}{$ReqVer};
20830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2083162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $GccVer = get_dumpversion($Cmd))
2083262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2083362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $GccVer=~s/(-|_)[a-z_]+.*\Z//; # remove suffix (like "-haiku-100818")
2083462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(cmpVersions($GccVer, $ReqVer)>=0) {
2083562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = $Cmd);
2083662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2083762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2083862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = "");
20839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_depth($)
20842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_depth"}{$_[0]}) {
208449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_depth"}{$_[0]};
20845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_depth"}{$_[0]} = ($_[0]=~tr![\/\\]|\:\:!!));
20847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20849570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerGccHeaders()
20850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20851570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerGccHeaders"}); # this function should be called once
20852570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20853570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultGccPaths)
20854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20855570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($Path,"f");
20856570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
20857570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $HPath (@Headers)
20858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20859570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($HPath);
20860570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultGccHeader{$FileName})
20861570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
20862570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $DefaultGccHeader{$FileName} = $HPath;
20863570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
20864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20866570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerGccHeaders"} = 1;
20867570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
20868570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20869570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerCppHeaders()
20870570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
20871570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerCppHeaders"}); # this function should be called once
20872570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20873570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $CppDir (@DefaultCppPaths)
20874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20875570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($CppDir,"f");
20876570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
20877570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (@Headers)
20878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20879570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($Path);
20880570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultCppHeader{$FileName})
20881570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
20882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DefaultCppHeader{$FileName} = $Path;
20883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20886570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerCppHeaders"} = 1;
20887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname($$$)
20890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
208919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $_[0]);
208929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]}) {
208939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]};
20894dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
208959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]} = parse_libname_I(@_));
208969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
208979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
208989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub parse_libname_I($$$)
208999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
209009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Name, $Type, $Target) = @_;
20901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Target eq "symbian") {
20903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_symbian($Name, $Type);
20904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Target eq "windows") {
20906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_windows($Name, $Type);
20907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20908fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20909fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    # unix
20910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT($Target);
20911a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Name=~/((((lib|).+?)([\-\_][\d\-\.\_]+.*?|))\.$Ext)(\.(.+)|)\Z/)
20912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libSDL-1.2.so.0.7.1
20913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # libwbxml2.so.0.0.18
20914a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko      # libopcodes-2.21.53-system.20110810.so
20915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
20916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2
20917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
20918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
20921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2.so
20922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2.so
20923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
20924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
20926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20927a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(defined $7
20928a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            and $7 ne "")
20929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0.7.1
20930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $7;
20931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # libc-2.5.so (=>2.5 version)
20934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MV = $5;
20935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MV=~s/\A[\-\_]+//g;
20936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MV;
20937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
20940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL
20941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
20942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
20943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
20945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SDL
20946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # wbxml
20947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
20948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
20951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_symbian($$)
20954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
20956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("symbian");
20957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/(((.+?)(\{.+\}|))\.$Ext)\Z/)
20958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libpthread{00010001}.dso
20959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
20960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}
20961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
20964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}.dso
20965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
20966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
20968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 00010001
20969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $V = $4;
20970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $V=~s/\{(.+)\}/$1/;
20971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $V;
20972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
20974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread
20975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
20976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
20978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # pthread
20979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
20980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
20983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_windows($$)
20986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
20988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("windows");
20989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/((.+?)\.$Ext)\Z/)
20990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # netapi32.dll
20991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
20992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
20993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
20994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
20996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32.dll
20997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
20998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # DLL version embedded
21001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # at binary-level
21002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
21003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi
21010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($2);
21011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub shortest_name($)
21017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
21019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove prefix
21020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\A(lib|open)//;
21021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove suffix
21022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/[\W\d_]+\Z//i;
21023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/([a-z]{2,})(lib)\Z/$1/i;
21024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
21025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createSymbolsList($$$$$)
21028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($DPath, $SaveTo, $LName, $LVersion, $ArchName) = @_;
21030ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    read_ABI_Dump(1, $DPath);
21032ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    prepareSymbols(1);
21033ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SymbolHeaderLib = ();
21035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Total = 0;
21036ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Get List
21038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
21039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not link_symbol($Symbol, 1, "-Deps"))
210411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
210441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Public", "Binary"))
21045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip other symbols
21046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
21049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HeaderName)
210501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
21054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DyLib)
210551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolHeaderLib{$HeaderName}{$DyLib}{$Symbol} = 1;
21059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Total+=1;
21060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Draw List
21062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SYMBOLS_LIST = "<h1>Public symbols in <span style='color:Blue;'>$LName</span> (<span style='color:Red;'>$LVersion</span>)";
21063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SYMBOLS_LIST .= " on <span style='color:Blue;'>".showArch($ArchName)."</span><br/>Total: $Total</h1><br/>";
21064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%SymbolHeaderLib))
21065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$SymbolHeaderLib{$HeaderName}}))
21067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %NS_Symbol = ();
21069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (keys(%{$SymbolHeaderLib{$HeaderName}{$DyLib}})) {
2107074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NS_Symbol{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
21071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NS_Symbol))
21073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
210741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SYMBOLS_LIST .= getTitle($HeaderName, $DyLib, $NameSpace);
21075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NS_Symbol{$NameSpace}});
21076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
21077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
21078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $SubReport = "";
21079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Symbol, 1);
21080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
2108162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
21082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Symbol=~/\A(_Z|\?)/)
21084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
210861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
210879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
21088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
21093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
21095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
21096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SYMBOLS_LIST .= $SubReport;
21102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SYMBOLS_LIST .= "<br/>\n";
21105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2110762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clear info
2110862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    (%TypeInfo, %SymbolInfo, %Library_Symbol, %DepSymbol_Library,
2110962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %DepLibrary_Symbol, %SymVer, %SkipTypes, %SkipSymbols,
2111062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %NestedNameSpaces, %ClassMethods, %AllocableClass, %ClassNames,
2111162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %CompleteSignature, %SkipNameSpaces, %Symbol_Library, %Library_Symbol) = ();
21112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($Content_Counter, $ContentID) = (0, 0);
2111362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # print report
211141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $CssStyles = readModule("Styles", "SymbolsList.css");
211151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $JScripts = readModule("Scripts", "Sections.js");
211161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = "<a name='Top'></a>".$SYMBOLS_LIST.$TOP_REF."<br/>\n";
21117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Title = "$LName: public symbols";
21118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Keywords = "$LName, API, symbols";
21119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Description = "List of symbols in $LName ($LVersion) on ".showArch($ArchName);
211201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."
21121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <body><div>\n$SYMBOLS_LIST</div>
2112241834e391a0873942fefa59729c95520a171a0e9Andrey Ponomarenko    <br/><br/>\n".getReportFooter()."
2112352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    </body></html>";
21124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile($SaveTo, $SYMBOLS_LIST);
21125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
211279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub add_target_libs($)
211289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
211299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach (@{$_[0]}) {
211309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TargetLibs{$_} = 1;
211319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
211329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
211339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
21134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_target_lib($)
21135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LName = $_[0];
21137a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(not $LName) {
21138a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return 0;
21139a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
21140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibraryName
21141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $LName!~/\Q$TargetLibraryName\E/) {
21142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%TargetLibs)
21145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{$LName}
21146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{parse_libname($LName, "name+ext", $OStarget)}) {
21147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
21150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21152850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub is_target_header($$)
21153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # --header, --headers-list
21154850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($H, $V) = @_;
21155850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(keys(%{$TargetHeaders{$V}}))
21156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21157850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($TargetHeaders{$V}{$H}) {
21158850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
21159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21161850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
21162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLibs($)
21165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows")
21168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dumpbin.exe will crash
21169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # without VS Environment
21170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        check_win32_env();
21171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
211721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    readSymbols($LibVersion);
21173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2117462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
21175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub dump_sorting($)
21178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21179989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my $Hash = $_[0];
21180989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if(not $Hash);
21181989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my @Keys = keys(%{$Hash});
21182989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if($#Keys<0);
21183989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Keys[0]=~/\A\d+\Z/)
21184989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # numbers
21185989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {int($a)<=>int($b)} @Keys];
21186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21187989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    else
21188989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # strings
21189989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {$a cmp $b} @Keys];
21190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printMsg($$)
21194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Type, $Msg) = @_;
21196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/\AINFO/) {
21197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg = $Type.": ".$Msg;
21198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/_C\Z/) {
21200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg .= "\n";
21201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet)
21203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet option
21204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($COMMON_LOG_PATH, $Msg);
21205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "ERROR") {
21209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print STDERR $Msg;
21210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print $Msg;
21213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitStatus($$)
21218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Code, $Msg) = @_;
21220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("ERROR", $Msg);
21221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{$Code});
21222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitReport()
21225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # the tool has run without any errors
21226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printReport();
21227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMPILE_ERRORS)
21228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # errors in headers may add false positives/negatives
21229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compile_Error"});
21230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
212311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $RESULT{"Binary"}{"Problems"})
212321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
212331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
212341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly and $RESULT{"Source"}{"Problems"})
212361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
212371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
212381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($RESULT{"Source"}{"Problems"}
212401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $RESULT{"Binary"}{"Problems"})
212411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
21242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
21243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
21245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compatible"});
21246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readRules($)
21250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Kind = $_[0];
21252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $RULES_PATH{$Kind}) {
21253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'".$RULES_PATH{$Kind}."\'");
21254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($RULES_PATH{$Kind});
21256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(my $Rule = parseTag(\$Content, "rule"))
21257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RId = parseTag(\$Rule, "id");
21259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Properties = ("Severity", "Change", "Effect", "Overcome", "Kind");
21260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prop (@Properties) {
21261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Value = parseTag(\$Rule, lc($Prop)))
21262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value=~s/\n[ ]*//;
21264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompatRules{$Kind}{$RId}{$Prop} = $Value;
21265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompatRules{$Kind}{$RId}{"Kind"}=~/\A(Symbols|Parameters)\Z/) {
21268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Symbols";
21269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Types";
21272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
212761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReportPath($)
212771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
212781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
212791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = "compat_reports/$TargetLibraryName/".$Descriptor{1}{"Version"}."_to_".$Descriptor{2}{"Version"};
212801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
212811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
212821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath)
212831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --bin-report-path
212841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $BinaryReportPath;
212851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
212871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
212881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
212891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
212911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
212921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/abi_compat_report.$ReportFormat";
212931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
212941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
212951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source")
212961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
212971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath)
212981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --src-report-path
212991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $SourceReportPath;
213001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
213021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
213031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
213041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
213061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
213071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/src_compat_report.$ReportFormat";
213081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
213111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
213131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
213141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
213151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
213171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
213181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/compat_report.$ReportFormat";
213191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
213221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
213231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub printStatMsg($)
213241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
213251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
213261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    printMsg("INFO", "total \"$Level\" compatibility problems: ".$RESULT{$Level}{"Problems"}.", warnings: ".$RESULT{$Level}{"Warnings"});
213271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
213281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
213291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub listAffected($)
213301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
213311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
213321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $List = "";
213331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach (keys(%{$TotalAffected{$Level}}))
213341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($StrictCompat and $TotalAffected{$Level}{$_} eq "Low")
213361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip "Low"-severity problems
213371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
213381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $List .= "$_\n";
213401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = get_dirname(getReportPath($Level));
213421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
213431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/abi_affected.txt", $List);
213441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source") {
213461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/src_affected.txt", $List);
213471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
213481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
213491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printReport()
21351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating compatibility report ...");
213531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    createReport();
213541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
213551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}
213571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $RESULT{"Source"}{"Problems"}) {
213581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (Binary: ".$RESULT{"Binary"}{"Affected"}."\%, Source: ".$RESULT{"Source"}{"Affected"}."\%)");
213591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
213611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
213621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
213641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
213651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
213661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
213671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
213681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
21369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
213721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}) {
213741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Binary"}{"Affected"}."\%)");
213751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
213771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
213781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
213801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
213811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
213821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
213831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
213861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
213871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Source"}{"Problems"}) {
213881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Source"}{"Affected"}."\%)");
213891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
213911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
213921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
213931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
213941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
213951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
213961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
213971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
214001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport or not $DoubleReport)
214020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # --binary or --source
214031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility report has been generated to stdout");
214041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
214061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility reports have been generated to stdout");
214081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
214101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
214111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
214130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
214141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Join"));
214151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($DoubleReport)
214171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed reports:\n  ".getReportPath("Binary")."\n  ".getReportPath("Source"));
214191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($BinaryOnly)
214211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --binary
214221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Binary"));
214231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($SourceOnly)
214251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --source
214261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Source"));
214271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub check_win32_env()
21432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $ENV{"DevEnvDir"}
21434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $ENV{"LIB"}) {
21435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't start without VS environment (vsvars32.bat)");
21436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
214395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub diffSets($$)
214405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
214415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my ($S1, $S2) = @_;
214425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK1 = keys(%{$S1});
214435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK2 = keys(%{$S2});
214445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($#SK1!=$#SK2) {
214455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return 1;
214465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
214475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    foreach my $K1 (@SK1)
214485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
214495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not defined $S2->{$K1}) {
214505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            return 1;
214515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
214525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
214535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return 0;
214545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
214555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
214566bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenkosub defaultDumpPath($$)
214576bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko{
214586bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my ($N, $V) = @_;
214596bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    return "abi_dumps/".$N."/".$N."_".$V.".abi.".$AR_EXT; # gzipped by default
214606bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko}
214616bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko
21462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_ABI_Dump()
21463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -e $DumpAPI) {
21465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$DumpAPI\'");
21466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2146754040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko
21468ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($DumpAPI)) {
21469ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $DumpAPI);
21470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21471ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21472ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $DumpAPI));
21473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21476ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    { # set to default: N
21477ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $Descriptor{1}{"Version"} = "N";
21478fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("inc|lib|bin|gcc"); # complete analysis
2148274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
214836bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko    my $DumpPath = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
214848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($OutputDumpPath)
214858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # user defined path
214868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $DumpPath = $OutputDumpPath;
2148774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
214888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Archive = ($DumpPath=~s/\Q.$AR_EXT\E\Z//g);
214898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
214908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $Archive and not $StdOut)
214918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # check archive utilities
214928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup eq "windows")
214938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using zip
214948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $ZipCmd = get_CmdPath("zip");
214958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $ZipCmd) {
214968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"zip\"");
214978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2149874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
214998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
215008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using tar and gzip
215018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
215028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $TarCmd) {
215038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\"");
215048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
215058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
215068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $GzipCmd) {
215078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\"");
215088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2150974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2151074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2151174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2151201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2151301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2151401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckHeadersOnly) {
2151501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readLibs(1);
2151601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2151701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($CheckHeadersOnly) {
2151801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            setLanguage(1, "C++");
2151901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21520ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2152154040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
21522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2152301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2152401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2152501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Descriptor{1}{"Headers"}) {
2152601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readHeaders(1);
2152701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21529850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    cleanDump(1);
21530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{1}}))
21531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check if created dump is valid
21532ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $ExtendedCheck)
21533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckHeadersOnly) {
21535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty");
21536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
21538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection");
21539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeadersInfo = ();
21543fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $HPath (keys(%{$Registered_Headers{1}})) {
21544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HeadersInfo{$Registered_Headers{1}{$HPath}{"Identity"}} = $Registered_Headers{1}{$HPath}{"Pos"};
21545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21546570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ExtraDump)
21547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # add unmangled names to the ABI dump
21548570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Names = ();
21549570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"}) {
21552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@Names, $MnglName);
21553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21555570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        translateSymbols(@Names, 1);
21556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"})
21559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
21560570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Unmangled = $tr_name{$MnglName})
21561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
21562570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($MnglName ne $Unmangled) {
21563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $SymbolInfo{1}{$InfoId}{"Unmangled"} = $Unmangled;
21564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
21565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
21566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
21569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my %GccConstants = (); # built-in GCC constants
21571fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (keys(%{$Constants{1}}))
21572fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
21573fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not defined $Constants{1}{$Name}{"Header"})
21574fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
21575fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $GccConstants{$Name} = $Constants{1}{$Name}{"Value"};
21576fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($Constants{1}{$Name});
21577fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
21578fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21579fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating library ABI dump ...");
2158101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %ABI = (
21582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "TypeInfo" => $TypeInfo{1},
21583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolInfo" => $SymbolInfo{1},
21584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Symbols" => $Library_Symbol{1},
2158562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "DepSymbols" => $DepLibrary_Symbol{1},
21586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolVersion" => $SymVer{1},
21587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryVersion" => $Descriptor{1}{"Version"},
21588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryName" => $TargetLibraryName,
21589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Language" => $COMMON_LANGUAGE{1},
21590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipTypes" => $SkipTypes{1},
21591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipSymbols" => $SkipSymbols{1},
21592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipNameSpaces" => $SkipNameSpaces{1},
21593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipHeaders" => $SkipHeadersList{1},
21594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Headers" => \%HeadersInfo,
21595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Constants" => $Constants{1},
21596fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        "GccConstants" => \%GccConstants,
21597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "NameSpaces" => $NestedNameSpaces{1},
21598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Target" => $OStarget,
21599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Arch" => getArch(1),
21600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "WordSize" => $WORD_SIZE{1},
21601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "GccVersion" => get_dumpversion($GCC_PATH),
21602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_DUMP_VERSION" => $ABI_DUMP_VERSION,
21603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_COMPLIANCE_CHECKER_VERSION" => $TOOL_VERSION
21604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
216055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(diffSets($TargetHeaders{1}, \%HeadersInfo)) {
2160601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"TargetHeaders"} = $TargetHeaders{1};
216075c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
216085c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML) {
2160901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"XML_ABI_DUMP_VERSION"} = $XML_ABI_DUMP_VERSION;
216105c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
21611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
21612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
2161301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"Mode"} = "Extended";
21614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
216151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly)
216161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
2161701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"BinOnly"} = 1;
216181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2161974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
21620fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # --extra-dump
2162174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ABI{"Extra"} = 1;
21622fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"UndefinedSymbols"} = $UndefinedSymbols{1};
21623fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"Needed"} = $Library_Needed{1};
2162474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
216255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
216265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $ABI_DUMP = "";
216275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML)
216285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
216295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        loadModule("XmlDump");
2163001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = createXmlDump(\%ABI);
216315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
216321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
216331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
2163401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = Dumper(\%ABI);
216351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
21636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
21637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --stdout option
216385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print STDOUT $ABI_DUMP;
21639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI dump has been generated to stdout");
21640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
21641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # write to gzipped file
21644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($DDir, $DName) = separate_path($DumpPath);
21645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DPath = $TMP_DIR."/".$DName;
216465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $Archive) {
216475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $DPath = $DumpPath;
216485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
216495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DDir);
21651850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21652850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(DUMP, ">", $DPath) || die ("can't open file \'$DPath\': $!\n");
216535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print DUMP $ABI_DUMP;
21654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(DUMP);
21655850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -s $DPath) {
21657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't create ABI dump because something is going wrong with the Data::Dumper module");
21658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2165907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Archive) {
2166007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $DumpPath = createArchive($DPath, $DDir);
216615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
2166207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
21663ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($OutputDumpPath) {
21664ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $OutputDumpPath");
21665ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
21666ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        else {
216675c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $DumpPath");
216685c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
21669ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        printMsg("INFO", "you can transfer this dump everywhere and use instead of the ".$Descriptor{1}{"Version"}." version descriptor");
21670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub quickEmptyReports()
21674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # Quick "empty" reports
21675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # 4 times faster than merging equal dumps
21676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # NOTE: the dump contains the "LibraryVersion" attribute
21677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # if you change the version, then your dump will be different
21678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME: use -v1 and v2 options for comparing dumps
21679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # and don't change version in the XML descriptor (and dumps)
21680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME 2: separate meta info from the dumps in ACC 2.0
21681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-s $Descriptor{1}{"Path"} == -s $Descriptor{2}{"Path"})
21682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath1 = unpackDump($Descriptor{1}{"Path"});
21684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath2 = unpackDump($Descriptor{2}{"Path"});
21685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($FilePath1 and $FilePath2)
21686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2168701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Line = readLineNum($FilePath1, 0);
2168801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($Line=~/xml/)
2168901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # XML format
2169001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                # is not supported yet
2169101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return;
2169201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2169301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
21694850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            local $/ = undef;
21695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21696850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP1, $FilePath1);
21697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content1 = <DUMP1>;
21698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP1);
21699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP2, $FilePath2);
21701850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content2 = <DUMP2>;
21702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP2);
21703850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21704850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Content1 eq $Content2)
21705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21706850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21707850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content2;
21708850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # read a number of headers, libs, symbols and types
21710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $ABIdump = eval($Content1);
21711850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21712850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21713850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content1;
21714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump) {
217169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
21717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"TypeInfo"})
217191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"TypeInfo"} = $ABIdump->{"TypeDescr"};
21721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"SymbolInfo"})
217231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"SymbolInfo"} = $ABIdump->{"FuncDescr"};
21725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21726fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                read_Source_DumpInfo($ABIdump, 1);
21727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Libs_DumpInfo($ABIdump, 1);
21728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 1);
21729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 2);
217301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
217311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Binary"}} = %{$ABIdump->{"TypeInfo"}};
217321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Source"}} = %{$ABIdump->{"TypeInfo"}};
217331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
217341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Binary"}} = %{$ABIdump->{"SymbolInfo"}};
217351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Source"}} = %{$ABIdump->{"SymbolInfo"}};
217361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{1}{"Version"} = $TargetVersion{1}?$TargetVersion{1}:$ABIdump->{"LibraryVersion"};
21738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{2}{"Version"} = $TargetVersion{2}?$TargetVersion{2}:$ABIdump->{"LibraryVersion"};
21739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitReport();
21740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub initLogging($)
21746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create log directory
21749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LOG_DIR, $LOG_FILE) = ("logs/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"}, "log.txt");
21750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OutputLogPath{$LibVersion})
21751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined by -log-path option
21752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($LOG_DIR, $LOG_FILE) = separate_path($OutputLogPath{$LibVersion});
21753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($LOG_DIR);
21756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $LOG_PATH{$LibVersion} = get_abs_path($LOG_DIR)."/".$LOG_FILE;
21758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
21759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug directory
21760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $DEBUG_PATH{$LibVersion} = "debug/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"};
2176174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2176274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $ExtraInfo)
2176374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # enable --extra-info
2176474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $ExtraInfo = $DEBUG_PATH{$LibVersion}."/extra-info";
2176574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
21766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2176735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    resetLogging($LibVersion);
21768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeLog($$)
21771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Msg) = @_;
21773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($LOG_PATH{$LibVersion}, $Msg);
21775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub resetLogging($)
21779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode!~/a|n/)
21782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # remove old log
21783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($LOG_PATH{$LibVersion});
2178435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Debug) {
2178535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            rmtree($DEBUG_PATH{$LibVersion});
2178635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
21787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printErrorLog($)
21791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "see log for details:\n  ".$LOG_PATH{$LibVersion}."\n");
21795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isDump($)
21799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21800b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.tar\.gz(\.\w+|)|\.zip|\.xml|)\Z/)
21801b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    { # NOTE: name.abi.tar.gz.amd64 (dh & cdbs)
218029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $1;
218039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
218049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return 0;
218059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
218069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
218079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub isDump_U($)
218089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
21809b9ed4c907bb048c3aa651b7d88cf230a8a63fd8aAndrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.xml|)\Z/) {
21810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $1;
21811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
21813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
218151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareInit()
21816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # read input XML descriptors or ABI dumps
21818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Path"}) {
218190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-old option is not specified");
21820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21821ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{1}{"Path"}) {
21822ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{1}{"Path"}."\'");
21823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21824ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Path"}) {
218260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-new option is not specified");
21827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21828ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not -e $Descriptor{2}{"Path"}) {
21829ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'".$Descriptor{2}{"Path"}."\'");
21830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21831ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("bin"); # to extract dumps
21833ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})
21834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{2}{"Path"}))
21835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # optimization: equal ABI dumps
21836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        quickEmptyReports();
21837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21838ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "preparation, please wait ...");
21840ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21841ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{1}{"Path"})) {
21842ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(1, $Descriptor{1}{"Path"});
21843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21844ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21845ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(1, createDescriptor(1, $Descriptor{1}{"Path"}));
21846ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
21847ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21848ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(isDump($Descriptor{2}{"Path"})) {
21849ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        read_ABI_Dump(2, $Descriptor{2}{"Path"});
21850ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
21851ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    else {
21852ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readDescriptor(2, createDescriptor(2, $Descriptor{2}{"Path"}));
21853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21854fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21855fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21856fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
21857fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
21858fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21859fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21860fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{2}{"Version"})
21861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: Y
21862fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{2}{"Version"} = "Y";
21863fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21864fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(2);
21867ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21868ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # check input data
21869ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}) {
21870ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d1");
21871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21872ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"}) {
21873ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        exitStatus("Error", "can't find header files info in descriptor d2");
21874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21875ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21876ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(not $CheckHeadersOnly)
21877bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
21878ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{1}{"Libs"}) {
21879ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d1");
21880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21881ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        if(not $Descriptor{2}{"Libs"}) {
21882ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko            exitStatus("Error", "can't find libraries info in descriptor d2");
21883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21885ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
21886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UseDumps)
21887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --use-dumps
21888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # parallel processing
218896bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath1 = defaultDumpPath($TargetLibraryName, $Descriptor{1}{"Version"});
218906bdaa963dbe179ebc5a64f1ff4171bcc31587cdaAndrey Ponomarenko        my $DumpPath2 = defaultDumpPath($TargetLibraryName, $Descriptor{2}{"Version"});
2189174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2189274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath1);
2189374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath2);
2189474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
21895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $pid = fork();
21896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($pid)
21897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # dump on two CPU cores
21898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{1}{"Path"}, "-l", $TargetLibraryName);
21899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{1}) {
21900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{1});
21901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{1}) {
21903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{1});
21904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
21906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
21907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21908dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
21909dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
21910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
21911dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
21912dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
21913dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
21914dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
21915dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
21916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
21918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
21919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
21921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
21922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{1}) {
21924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{1});
21925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21926850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
21927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
21928850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
21929850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
21930850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
21931850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2193262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2193362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2193462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2193501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2193601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2193701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
21938f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
21939f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
21940f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
21941850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
21942850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
21943850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2194462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
21945850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
21946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2194774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath1) {
21948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
21949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
21952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # child
21953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{2}{"Path"}, "-l", $TargetLibraryName);
21954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{2}) {
21955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{2});
21956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{2}) {
21958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{2});
21959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
21961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
21962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21963dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
21964dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
21965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
21966dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
21967dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
21968dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
21969dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
21970dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
21971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
21973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
21974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
21976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
21977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{2}) {
21979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{2});
21980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21981850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
21982850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
21983850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
21984850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
21985850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
21986850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2198762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2198862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2198962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2199001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2199101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2199201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
21993f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
21994f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
21995f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
21996850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
21997850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
21998850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2199962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22000850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2200274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath2) {
22003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(0);
22007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        waitpid($pid, 0);
2201014b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko
22011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @CMP_PARAMS = ("-l", $TargetLibraryName);
2201274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d1", $DumpPath1);
2201374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d2", $DumpPath2);
2201414b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        if($TargetTitle ne $TargetLibraryName) {
2201514b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-title", $TargetTitle);
22016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShowRetVal) {
22018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-show-retval");
22019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc) {
22021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-cross-gcc", $CrossGcc);
22022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2202335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-logging-mode", "a");
2202435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Quiet) {
22025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-quiet");
22026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
22027dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($ReportFormat and $ReportFormat ne "html")
22028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # HTML is default format
22029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-format", $ReportFormat);
22030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
220311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath) {
220321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-path", $OutputReportPath);
220331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
220341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath) {
220351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-bin-report-path", $BinaryReportPath);
220361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
220371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath) {
220381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-src-report-path", $SourceReportPath);
220391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
220401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($LoggingPath) {
220411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-log-path", $LoggingPath);
220421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22043f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckHeadersOnly) {
22044f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-headers-only");
22045f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22046f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($BinaryOnly) {
22047f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-binary");
22048f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22049f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($SourceOnly) {
22050f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-source");
22051f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2205262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug)
2205362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2205462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-debug");
2205562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running perl $0 @CMP_PARAMS");
22056850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
22057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system("perl", $0, @CMP_PARAMS);
22058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($?>>8);
22059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"}
22061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Dump"})
22062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # need GCC toolchain to analyze
22063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # header files and libraries
22064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("inc|lib|gcc");
22065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
22067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(1);
22070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(1, "C++");
22073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22074ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(1);
2207554040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize(1);
22076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Dump"})
22078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(2);
22081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(2, "C++");
22084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22085ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        searchForHeaders(2);
2208654040a158d7d3fdeba2c37a1e88f14fac6ddd407Andrey Ponomarenko        $WORD_SIZE{2} = detectWordSize(2);
22087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($WORD_SIZE{1} ne $WORD_SIZE{2})
22089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # try to synch different WORD sizes
2209162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.1"))
22092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{1} = $WORD_SIZE{2};
22094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{2}." bytes");
22095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2209662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(not checkDump(2, "2.1"))
22097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{2} = $WORD_SIZE{1};
22099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{1}." bytes");
22100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $WORD_SIZE{1}
22103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $WORD_SIZE{2})
22104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2210562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{1} = "4";
2210662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{2} = "4";
22107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Dump"})
22109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(1);
22111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{2}{"Dump"})
22113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(2);
22115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath and not keys(%{$Symbol_Library{1}})) {
22117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("WARNING", "the application ".get_filename($AppPath)." has no symbols imported from the $SLIB_TYPE libraries");
22118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22119ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    # process input data
22120ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{1}{"Headers"}
22121ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{1}{"Dump"}) {
22122ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(1);
22123ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    }
22124ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if($Descriptor{2}{"Headers"}
22125ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    and not $Descriptor{2}{"Dump"}) {
22126ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        readHeaders(2);
22127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22128850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22129850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
22130850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %SystemHeaders = ();
22131850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %mangled_name_gcc = ();
22132850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
221331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(1);
221341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(2);
221351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
22136850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
221371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %SymbolInfo = ();
221381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
221391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Virtual Tables
221401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(1);
221411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(2);
221421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
2214362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "1.22")
2214462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and checkDump(2, "1.22"))
221451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # support for old ABI dumps
221461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $ClassName (keys(%{$VirtualTable{2}}))
221471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
221481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($ClassName=~/</)
221491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # templates
221501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not defined $VirtualTable{1}{$ClassName})
221511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # synchronize
221521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    delete($VirtualTable{2}{$ClassName});
221531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
221541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
221551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
221561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
221571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
221581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(1);
221591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(2);
221601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
221611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(1);
221621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(2);
221631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
221641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Other
221651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(1);
221661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(2);
221671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
221681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    detectChangedTypedefs();
221691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
221701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
221711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareAPIs($)
221721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
221731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
22174ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
221751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    readRules($Level);
22176f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    loadModule("CallConv");
22177ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
221781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
221791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing ABIs ...");
221801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
221811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
221821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing APIs ...");
221831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22184ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
221851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
221861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
22187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # added/removed in headers
221881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded_H($Level);
221891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved_H($Level);
22190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
221921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
221931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded($Level);
221941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved($Level);
221951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22196ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22197ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    mergeSymbols($Level);
22198ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko    if(keys(%{$CheckedSymbols{$Level}})) {
22199ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        mergeConstants($Level);
222001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22201f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
22202f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Cache{"mergeTypes"} = (); # free memory
22203f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
222041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
222051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
222061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in headers
222071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeHeaders($Level);
222081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
222101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
222111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeLibs($Level);
22212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
222159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSysOpts()
22216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Opts = (
22218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "OStarget"=>$OStarget,
22219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Debug"=>$Debug,
22220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Quiet"=>$Quiet,
22221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "LogMode"=>$LogMode,
22222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CheckHeadersOnly"=>$CheckHeadersOnly,
22223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "SystemRoot"=>$SystemRoot,
22225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "GCC_PATH"=>$GCC_PATH,
22226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetSysInfo"=>$TargetSysInfo,
22227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossPrefix"=>$CrossPrefix,
22228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetLibraryName"=>$TargetLibraryName,
22229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossGcc"=>$CrossGcc,
22230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "UseStaticLibs"=>$UseStaticLibs,
222319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NoStdInc"=>$NoStdInc,
222329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
222339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BinaryOnly" => $BinaryOnly,
222349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SourceOnly" => $SourceOnly
22235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
22236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Opts;
22237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2223974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_CodeError($)
22240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %CODE_ERROR = reverse(%ERROR_CODE);
22242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CODE_ERROR{$_[0]};
22243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub scenario()
22246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # enable quiet mode
22249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Quiet = 1;
222501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 1;
22251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22252dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $LogMode)
22253dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # default
22254dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $LogMode = "w";
22255dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
22256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UserLang)
22257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C++
22258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UserLang = uc($UserLang);
22259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{1}=$UserLang;
22260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{2}=$UserLang;
22261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LoggingPath)
22263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{1} = $LoggingPath;
22265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{2} = $LoggingPath;
22266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Quiet) {
22267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $COMMON_LOG_PATH = $LoggingPath;
22268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22270e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if($Quick) {
22271e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        $ADD_TMPL_INSTANCES = 0;
22272e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
222735c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($OutputDumpPath)
222745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
2227574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not isDump($OutputDumpPath)) {
222765c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "the dump path should be a path to *.abi.$AR_EXT or *.abi file");
222775c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
222785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
222791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $SourceOnly)
222801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # both --binary and --source
222811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # is the default mode
222825e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        if(not $CmpSystems)
222835e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        {
222845e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $BinaryOnly = 0;
222855e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko            $SourceOnly = 0;
222865e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko        }
222875e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
222881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 1;
222891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
222905e80d97d6b01ae2e8a62624f27178aa7f6e8d2f5Andrey Ponomarenko
222911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
222921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
222931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $DoubleReport = 0;
222941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JoinReport = 1;
222951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
222961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
222971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly or $SourceOnly)
222981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary or --source
222991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 0;
223001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
223011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
223021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($UseXML)
223031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --xml option
223041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = "xml";
223055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "xml";
223061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat)
22308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate
223091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = lc($ReportFormat);
223101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat!~/\A(xml|html|htm)\Z/) {
223115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown report format \'$ReportFormat\'");
22312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
223131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat eq "htm")
223141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # HTM == HTML
223151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ReportFormat = "html";
223161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($ReportFormat eq "xml")
223181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-format=XML equal to --xml
223191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $UseXML = 1;
223201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # default: HTML
22324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ReportFormat = "html";
22325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
223265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($DumpFormat)
223275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
223285c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = lc($DumpFormat);
223295c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat!~/\A(xml|perl)\Z/) {
223305c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown ABI dump format \'$DumpFormat\'");
223315c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
223325c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat eq "xml")
223335c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # --dump-format=XML equal to --xml
223345c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $UseXML = 1;
223355c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
223365c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
223375c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
2233801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # default: Perl Data::Dumper
223395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "perl";
223405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet and $LogMode!~/a|n/)
22342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet log
22343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $COMMON_LOG_PATH) {
22344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($COMMON_LOG_PATH);
22345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
223474b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($ExtraInfo) {
22348570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CheckUndefined = 1;
22349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool and $UseDumps)
22351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test && --use-dumps == --test-dump
22352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestDump = 1;
22353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
223548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerant)
223558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # enable all
223568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Tolerance = 1234;
223578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
22358570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Help)
22359570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        HELP_MESSAGE();
22361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22363ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    if($InfoMsg)
22364ed4d38990dffaec234112705c533d19a9abc9e68Andrey Ponomarenko    {
22365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        INFO_MESSAGE();
22366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22368570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ShowVersion)
22369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2237052b2e35f3dfda9369631beeb5d5480df65c47950Andrey 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.");
22371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($DumpVersion)
22374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", $TOOL_VERSION);
22376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck) {
22379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CheckHeadersOnly = 1;
22380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot_Opt)
22382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user defined root
22383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $SystemRoot_Opt) {
22384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$SystemRoot\'");
22385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot = $SystemRoot_Opt;
22387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot=~s/[\/]+\Z//g;
22388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
22389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SystemRoot = get_abs_path($SystemRoot);
22390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Data::Dumper::Sortkeys = 1;
22393989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2239462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($SortDump)
2239562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2239662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Useperl = 1;
2239762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Sortkeys = \&dump_sorting;
2239862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
22399989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
22400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibsPath)
22401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetLibsPath) {
22403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetLibsPath\'");
22404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Lib (split(/\s*\n\s*/, readFile($TargetLibsPath))) {
22406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetLibs{$Lib} = 1;
22407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeadersPath)
22410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --headers-list
22411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetHeadersPath) {
22412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetHeadersPath\'");
22413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, readFile($TargetHeadersPath)))
22415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetHeaders{1}{$Header} = 1;
22417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetHeaders{2}{$Header} = 1;
22418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeader)
22421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --header
22422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetHeaders{1}{$TargetHeader} = 1;
22423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetHeaders{2}{$TargetHeader} = 1;
22424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool
22426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $TestDump)
22427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test, --test-dump
22428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to compile libs
22429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("RegTests");
22430f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        testTool($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, $DumpFormat,
22431ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        $LIB_EXT, $GCC_PATH, $SortDump, $CheckHeadersOnly);
22432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpSystem)
22435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-system
2243652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2243752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not $TargetSysInfo) {
2243852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Error", "-sysinfo option should be specified to dump system ABI");
2243952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2244052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
2244152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -d $TargetSysInfo) {
2244252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$TargetSysInfo\'");
2244352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2244452b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko
22445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
224469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($DumpSystem=~/\.(xml|desc)\Z/)
22447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # system XML descriptor
22448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -f $DumpSystem) {
22449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$DumpSystem\'");
22450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22451e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
22452e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $SDesc = readFile($DumpSystem);
22453e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            if(my $RelDir = $RelativeDirectory{1}) {
22454e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko                $SDesc =~ s/{RELPATH}/$RelDir/g;
22455e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            }
22456e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko
22457e32f7ea9f2b8c7c765a1383d9c097fefc5e463aaAndrey Ponomarenko            my $Ret = readSystemDescriptor($SDesc);
224589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            foreach (@{$Ret->{"Tools"}})
224599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
22460570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"bin"}, $_);
22461570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $TargetTools{$_} = 1;
22462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Ret->{"CrossPrefix"}) {
22464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CrossPrefix = $Ret->{"CrossPrefix"};
22465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($SystemRoot_Opt)
22468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -sysroot "/" option
22469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # default target: /usr/lib, /usr/include
22470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # search libs: /usr/lib and /lib
22471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/lib") {
22472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/lib'");
22473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/lib") {
22475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/lib'");
22476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/include") {
22478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/include'");
22479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readSystemDescriptor("
22481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <name>
22482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DumpSystem
22483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </name>
22484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
22485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/include
22486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
22487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
22488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/lib
22489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>
22490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <search_libs>
22491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/lib
22492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </search_libs>");
22493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "-sysroot <dirpath> option should be specified, usually it's \"/\"");
22496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to check symbols
22498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
22499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # to run dumpbin.exe
22500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and undname.exe
22501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            check_win32_env();
22502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
225039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        dumpSystem(getSysOpts());
22504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CmpSystems)
22507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --cmp-systems
22508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin"); # to extract dumps
22509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
225109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        cmpSystems($Descriptor{1}{"Path"}, $Descriptor{2}{"Path"}, getSysOpts());
22511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryName) {
22514570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Error", "library name is not selected (-l option)");
22515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate library name
22518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryName=~/[\*\/\\]/) {
22519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "\"\\\", \"\/\" and \"*\" symbols are not allowed in the library name");
22520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2252214b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko    if(not $TargetTitle) {
2252314b8f02b2eb7226a7a813a6c079d12f693473cfaAndrey Ponomarenko        $TargetTitle = $TargetLibraryName;
22524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22525ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolsListPath)
22527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SymbolsListPath) {
22529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SymbolsListPath\'");
22530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SymbolsListPath))) {
22532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList{$Interface} = 1;
22533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2253552b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    if($TypesListPath)
2253652b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    {
2253752b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        if(not -f $TypesListPath) {
2253852b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TypesListPath\'");
2253952b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2254052b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        foreach my $Type (split(/\s*\n\s*/, readFile($TypesListPath))) {
2254152b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko            $TypesList{$Type} = 1;
2254252b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko        }
2254352b2e35f3dfda9369631beeb5d5480df65c47950Andrey Ponomarenko    }
22544fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($SkipSymbolsListPath)
22545fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
22546fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not -f $SkipSymbolsListPath) {
22547fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipSymbolsListPath\'");
22548fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22549a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SkipSymbolsListPath)))
22550a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko        {
22551a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{1}{$Interface} = 1;
22552a6d2e228ecb225354ad8aea37ec9f8c5fcbb29e0Andrey Ponomarenko            $SkipSymbols{2}{$Interface} = 1;
22553fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22554fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipHeadersPath)
22556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SkipHeadersPath) {
22558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipHeadersPath\'");
22559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, readFile($SkipHeadersPath)))
225611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register for both versions
225621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{1}{$Path} = 1;
225631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{2}{$Path} = 1;
22564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($CPath, $Type) = classifyPath($Path);
22565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{1}{$Type}{$CPath} = 1;
22566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{2}{$Type}{$CPath} = 1;
22567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ParamNamesPath)
22570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $ParamNamesPath) {
22572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$ParamNamesPath\'");
22573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Line (split(/\n/, readFile($ParamNamesPath)))
22575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~s/\A(\w+)\;//)
22577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
22578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Interface = $1;
2257962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Line=~/;(\d+);/)
2258062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    while($Line=~s/(\d+);(\w+)//) {
22582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$1}=$2;
22583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2258562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
2258662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Num = 0;
22588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Name (split(/;/, $Line)) {
22589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$Num++}=$Name;
22590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath)
22596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $AppPath) {
22598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$AppPath\'");
22599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22600ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko
22601ced3a6739d1f50d5b7360516d2464ca19f3cd0c5Andrey Ponomarenko        detect_default_paths("bin|gcc");
226021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $Interface (readSymbols_App($AppPath)) {
22603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList_App{$Interface} = 1;
22604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpAPI)
22607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-abi
22608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # make an API dump
22609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        create_ABI_Dump();
22610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($COMPILE_ERRORS);
22611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # default: compare APIs
22613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d1 <path>
22614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d2 <path>
226151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    compareInit();
226161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
226171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
226181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
226191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
226201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
226211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly) {
226221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
226231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
226241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly) {
226251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
226261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitReport();
22628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoscenario();
22631