abi-compliance-checker.pl revision 2489ef88760861175102e4508089608391beead3
1ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#!/usr/bin/perl
2ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko###########################################################################
32489ef88760861175102e4508089608391beead3Andrey Ponomarenko# ABI Compliance Checker (ACC) 1.99.8.3
41bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# A tool for checking backward compatibility of a C/C++ library API
5ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko#
6850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2009-2010 The Linux Foundation
7850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2009-2011 Institute for System Programming, RAS
8850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko# Copyright (C) 2011-2012 Nokia Corporation and/or its subsidiary(-ies)
98f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko# Copyright (C) 2011-2013 ROSA 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
20989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko#    - G++ (3.0-4.7, recommended 4.5 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
30989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko#    - MinGW (3.0-4.7, recommended 4.5 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# =============
41f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko#  ABI Dumper >= 0.98
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
672489ef88760861175102e4508089608391beead3Andrey Ponomarenkomy $TOOL_VERSION = "1.99.8.3";
68177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ABI_DUMP_VERSION = "3.2";
69ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OLDEST_SUPPORTED_VERSION = "1.18";
70fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy $XML_REPORT_VERSION = "1.1";
71f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy $XML_ABI_DUMP_VERSION = "1.2";
72ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OSgroup = get_OSgroup();
73ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ORIG_DIR = cwd();
74ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TMP_DIR = tempdir(CLEANUP=>1);
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
84ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy ($Help, $ShowVersion, %Descriptor, $TargetLibraryName, $GenerateTemplate,
85ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$TestTool, $DumpAPI, $SymbolsListPath, $CheckHeadersOnly_Opt, $UseDumps,
86ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko$CheckObjectsOnly_Opt, $AppPath, $StrictCompat, $DumpVersion, $ParamNamesPath,
87ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko%RelativeDirectory, $TargetLibraryFName, $TestDump, $CheckImpl, $LoggingPath,
88fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko%TargetVersion, $InfoMsg, $UseOldDumps, $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,
9407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko$SourceReportPath, $UseXML, $Browse, $OpenReport, $SortDump, $DumpFormat,
95177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko$ExtraInfo, $ExtraDump, $Force, $Tolerance, $Tolerant, $SkipSymbolsListPath,
96f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko$CheckInfo, $Quick, $AffectLimit, $AllAffected);
97ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
98ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CmdName = get_filename($0);
99ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_LibExt = (
100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic" => {
1019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"so",
102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "macos"=>"dylib",
103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"dll",
1049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"dso",
1059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"so"
106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static" => {
1089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "linux"=>"a",
109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "windows"=>"lib",
1109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "symbian"=>"lib",
1119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "default"=>"a"
112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_Archive = (
116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"zip",
117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"tar.gz"
118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ERROR_CODE = (
121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Compatible verdict
122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compatible"=>0,
123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Success"=>0,
124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible verdict
125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Incompatible"=>1,
126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Undifferentiated error code
127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Error"=>2,
128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # System command is not found
129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Not_Found"=>3,
130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot access input files
131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Access_Error"=>4,
132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot compile header files
133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Cannot_Compile"=>5,
134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Header compiled with errors
135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Compile_Error"=>6,
136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Invalid input ABI dump
137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Invalid_Dump"=>7,
138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Incompatible version of ABI dump
139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Dump_Version"=>8,
140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Cannot find a module
141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Module_Error"=>9,
142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty intersection between
143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # headers and shared objects
144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Intersection"=>10,
145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Empty set of symbols in headers
146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Empty_Set"=>11
147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HomePage = (
1501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    "Wiki"=>"http://ispras.linuxbase.org/index.php/ABI_compliance_checker",
151dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    "Dev1"=>"https://github.com/lvc/abi-compliance-checker",
152dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    "Dev2"=>"http://forge.ispras.ru/projects/abi-compliance-checker"
153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ShortUsage = "ABI Compliance Checker (ACC) $TOOL_VERSION
1561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey PonomarenkoA tool for checking backward compatibility of a C/C++ library API
157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoCopyright (C) 2012 ROSA Laboratory
158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoLicense: GNU LGPL or GNU GPL
159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUsage: $CmdName [options]
161dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey PonomarenkoExample: $CmdName -lib NAME -old OLD.xml -new NEW.xml
162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOLD.xml and NEW.xml are XML-descriptors:
164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/headers/
171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path/to/libraries/
175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMore info: $CmdName --help\n";
178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
179570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkoif($#ARGV==-1)
180570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $ShortUsage);
182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit(0);
183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (2 .. $#ARGV)
1861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # correct comma separated options
187570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ARGV[$_-1] eq ",")
188570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ARGV[$_-2].=",".$ARGV[$_];
190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        splice(@ARGV, $_-1, 2);
191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
192570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($ARGV[$_-1]=~/,\Z/)
193570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ARGV[$_-1].=$ARGV[$_];
195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        splice(@ARGV, $_, 1);
196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ARGV[$_]=~/\A,/
198570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    and $ARGV[$_] ne ",")
199570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ARGV[$_-1].=$ARGV[$_];
201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        splice(@ARGV, $_, 1);
202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGetOptions("h|help!" => \$Help,
206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "i|info!" => \$InfoMsg,
207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v|version!" => \$ShowVersion,
208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dumpversion!" => \$DumpVersion,
209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# general options
210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l|lib|library=s" => \$TargetLibraryName,
211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d1|old|o=s" => \$Descriptor{1}{"Path"},
212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d2|new|n=s" => \$Descriptor{2}{"Path"},
213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump|dump-abi|dump_abi=s" => \$DumpAPI,
214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "old-dumps!" => \$UseOldDumps,
215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# extra options
216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "d|descriptor-template!" => \$GenerateTemplate,
217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "app|application=s" => \$AppPath,
218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "static-libs!" => \$UseStaticLibs,
219989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  "cross-gcc|gcc-path=s" => \$CrossGcc,
220989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  "cross-prefix|gcc-prefix=s" => \$CrossPrefix,
221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysroot=s" => \$SystemRoot_Opt,
222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v1|version1|vnum=s" => \$TargetVersion{1},
223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "v2|version2=s" => \$TargetVersion{2},
224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "s|strict!" => \$StrictCompat,
225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "symbols-list=s" => \$SymbolsListPath,
226fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "skip-symbols=s" => \$SkipSymbolsListPath,
227fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "headers-list=s" => \$TargetHeadersPath,
228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "skip-headers=s" => \$SkipHeadersPath,
229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "header=s" => \$TargetHeader,
230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "headers-only|headers_only!" => \$CheckHeadersOnly_Opt,
231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "objects-only!" => \$CheckObjectsOnly_Opt,
232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "check-impl|check-implementation!" => \$CheckImpl,
233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "show-retval!" => \$ShowRetVal,
234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "use-dumps!" => \$UseDumps,
235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "nostdinc!" => \$NoStdInc,
236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-system=s" => \$DumpSystem,
237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "sysinfo=s" => \$TargetSysInfo,
238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "cmp-systems!" => \$CmpSystems,
239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "libs-list=s" => \$TargetLibsPath,
240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "ext|extended!" => \$ExtendedCheck,
241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "q|quiet!" => \$Quiet,
242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "stdout!" => \$StdOut,
243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-format=s" => \$ReportFormat,
2445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko  "dump-format=s" => \$DumpFormat,
2451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "xml!" => \$UseXML,
246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "lang=s" => \$UserLang,
2471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "binary|bin|abi!" => \$BinaryOnly,
2481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "source|src|api!" => \$SourceOnly,
2492489ef88760861175102e4508089608391beead3Andrey Ponomarenko  "limit-affected|affected-limit=s" => \$AffectLimit,
250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# other options
251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test!" => \$TestTool,
252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "test-dump!" => \$TestDump,
253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "debug!" => \$Debug,
25407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "cpp-compatible!" => \$CppCompat,
255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "p|params=s" => \$ParamNamesPath,
256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath1|relpath=s" => \$RelativeDirectory{1},
257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "relpath2=s" => \$RelativeDirectory{2},
258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "dump-path=s" => \$OutputDumpPath,
25962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "sort!" => \$SortDump,
260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "report-path=s" => \$OutputReportPath,
2611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "bin-report-path=s" => \$BinaryReportPath,
2621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "src-report-path=s" => \$SourceReportPath,
263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log-path=s" => \$LoggingPath,
264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log1-path=s" => \$OutputLogPath{1},
265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "log2-path=s" => \$OutputLogPath{2},
266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "logging-mode=s" => \$LogMode,
267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "list-affected!" => \$ListAffected,
268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "l-full|lib-full=s" => \$TargetLibraryFName,
2691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  "component=s" => \$TargetComponent_Opt,
27062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "b|browse=s" => \$Browse,
27107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  "open!" => \$OpenReport,
272570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-info=s" => \$ExtraInfo,
273570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  "extra-dump!" => \$ExtraDump,
2748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "force!" => \$Force,
2758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "tolerance=s" => \$Tolerance,
276177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "tolerant!" => \$Tolerant,
277e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  "check!" => \$CheckInfo,
278f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko  "quick!" => \$Quick,
279f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko  "all-affected!" => \$AllAffected
280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko) or ERR_MESSAGE();
281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ERR_MESSAGE()
283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "\n".$ShortUsage);
285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{"Error"});
286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_TYPE = $UseStaticLibs?"static":"dynamic";
289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLIB_TYPE = $LIB_TYPE;
290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoif($OSgroup!~/macos|windows/ and $SLIB_TYPE eq "dynamic")
291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # show as "shared" library
292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SLIB_TYPE = "shared";
293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $LIB_EXT = getLIB_EXT($OSgroup);
295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $AR_EXT = getAR_EXT($OSgroup);
296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $BYTE_SIZE = 8;
297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMMON_LOG_PATH = "logs/run.log";
298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HelpMessage="
300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoNAME:
301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  ABI Compliance Checker ($CmdName)
3020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  Check backward compatibility of a C/C++ library API
303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoDESCRIPTION:
3051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  ABI Compliance Checker (ACC) is a tool for checking backward binary and
3061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  source-level compatibility of a $SLIB_TYPE C/C++ library. The tool checks
3071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  header files and $SLIB_TYPE libraries (*.$LIB_EXT) of old and new versions and
3081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  analyzes changes in API and ABI (ABI=API+compiler ABI) that may break binary
3091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  and/or source-level compatibility: changes in calling stack, v-table changes,
3101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  removed symbols, renamed fields, etc. Binary incompatibility may result in
3111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  crashing or incorrect behavior of applications built with an old version of
3121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  a library if they run on a new one. Source incompatibility may result in
3131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  recompilation errors with a new library version.
314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  The tool is intended for developers of software libraries and maintainers
316dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  of operating systems who are interested in ensuring backward compatibility,
317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  i.e. allow old applications to run or to be recompiled with newer library
318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  versions.
319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
320dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  Also the tool can be used by ISVs for checking applications portability to
321dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  new library versions. Found issues can be taken into account when adapting
322dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko  the application to a new library version.
323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  This tool is free software: you can redistribute it and/or modify it
325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  under the terms of the GNU LGPL or GNU GPL.
326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoUSAGE:
328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  $CmdName [options]
329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXAMPLE:
3310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko  $CmdName -lib NAME -old OLD.xml -new NEW.xml
332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  OLD.xml and NEW.xml are XML-descriptors:
334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <version>
336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        1.0
337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </version>
338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <headers>
340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/header(s)/
341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/header(s)/
342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </headers>
344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <libs>
346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path1/to/library(ies)/
347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        /path2/to/library(ies)/
348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         ...
349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    </libs>
350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoINFORMATION OPTIONS:
352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -h|-help
353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print this help.
354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -i|-info
356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print complete info.
357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -v|-version
359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print version information.
360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -dumpversion
362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print the tool version ($TOOL_VERSION) and don't do anything else.
363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoGENERAL OPTIONS:
36507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l|-lib|-library NAME
366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Library name (without version).
367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
36807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d1|-old|-o PATH
369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 1st (old) library version.
370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      It may be one of the following:
371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         1. XML-descriptor (VERSION.xml file):
373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <version>
375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  1.0
376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </version>
377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <headers>
379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/header(s)/
380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/header(s)/
381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </headers>
383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              <libs>
385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path1/to/library(ies)/
386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  /path2/to/library(ies)/
387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                   ...
388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              </libs>
389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 ... (XML-descriptor template
391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                         can be generated by -d option)
392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         2. ABI dump generated by -dump option
394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         3. Directory with headers and/or $SLIB_TYPE libraries
395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         4. Single header file
396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         5. Single $SLIB_TYPE library
397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         6. Comma separated list of headers and/or libraries
398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If you are using an 2-6 descriptor types then you should
400570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      specify version numbers with -v1 and -v2 options too.
401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      For more information, please see:
4031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        http://ispras.linuxbase.org/index.php/Library_Descriptor
404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
40507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -d2|-new|-n PATH
406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Descriptor of 2nd (new) library version.
407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
40807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump|-dump-abi PATH
409570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create library ABI dump for the input XML descriptor. You can
410570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      transfer it anywhere and pass instead of the descriptor. Also
411570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      it can be used for debugging the tool.
412570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
413fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Supported ABI dump versions: 2.0<=V<=$ABI_DUMP_VERSION
414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -old-dumps
416fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Enable support for old-version ABI dumps ($OLDEST_SUPPORTED_VERSION<=V<2.0).\n";
417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub HELP_MESSAGE() {
419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", $HelpMessage."
420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFO:
421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko     $CmdName --info\n");
422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub INFO_MESSAGE()
425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "$HelpMessage
427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXTRA OPTIONS:
428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -d|-descriptor-template
429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Create XML-descriptor template ./VERSION.xml
430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -app|-application PATH
432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      This option allows to specify the application that should be checked
433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for portability to the new library version.
434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -static-libs
436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check static libraries instead of the shared ones. The <libs> section
437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the XML-descriptor should point to static libraries location.
438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
43907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cross-gcc|-gcc-path PATH
440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to the cross GCC compiler to use instead of the usual (host) GCC.
441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cross-prefix|-gcc-prefix PREFIX
443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      GCC toolchain prefix.
444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysroot DIR
446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify the alternative root directory. The tool will search for include
44707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      paths in the DIR/usr/include and DIR/usr/lib directories.
448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v1|-version1 NUM
450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 1st library version outside the descriptor. This option is needed
451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      if you have prefered an alternative descriptor type (see -d1 option).
452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      In general case you should specify it in the XML-descriptor:
454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <version>
455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              VERSION
456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </version>
457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
45807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -v2|-version2 NUM
459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Specify 2nd library version outside the descriptor.
460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -s|-strict
462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Treat all compatibility warnings as problems. Add a number of \"Low\"
463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      severity problems to the return value of the tool.
464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -headers-only
466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check header files without $SLIB_TYPE libraries. It is easy to run, but may
467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without detecting of added/removed symbols.
469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <libs> section
471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -objects-only
477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Check $SLIB_TYPE libraries without header files. It is easy to run, but may
478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      provide a low quality compatibility report with false positives and
479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      without analysis of changes in parameters and data types.
480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Alternatively you can write \"none\" word to the <headers> section
482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      in the XML-descriptor:
483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              none
485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -check-impl|-check-implementation
488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare canonified disassembled binary code of $SLIB_TYPE libraries to
489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      detect changes in the implementation. Add \'Problems with Implementation\'
490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      section to the report.
491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -show-retval
493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Show the symbol's return type in the report.
494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -symbols-list PATH
496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      This option allows to specify a file with a list of symbols (mangled
497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      names in C++) that should be checked, other symbols will not be checked.
498fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
499fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -skip-symbols PATH
500fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The list of symbols that should NOT be checked.
501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
502fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -headers-list PATH
503fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      The file with a list of headers, that should be checked/dumped.
504fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
50507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -skip-headers PATH
506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with the list of header files, that should not be checked.
507fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
508fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  -header NAME
509fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      Check/Dump ABI of this header only.
510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -use-dumps
512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Make dumps for two versions of a library and compare dumps. This should
513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      increase the performance of the tool and decrease the system memory usage.
514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -nostdinc
516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Do not search in GCC standard system directories for header files.
517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
51807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system NAME -sysroot DIR
51907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Find all the shared libraries and header files in DIR directory,
520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      create XML descriptors and make ABI dumps for each library. The result
521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      set of ABI dumps can be compared (--cmp-systems) with the other one
522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      created for other version of operating system in order to check them for
523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      compatibility. Do not forget to specify -cross-gcc option if your target
524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system requires some specific version of GCC compiler (different from
525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the host GCC). The system ABI dump will be generated to:
52607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_dumps/NAME/ARCH
527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
52807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-system DESCRIPTOR.xml
529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The same as the previous option but takes an XML descriptor of the target
530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      system as input, where you should describe it:
531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Primary sections */
533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <name>
535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Name of the system */
536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </name>
537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <headers>
539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to header files and/or
540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with header files, one per line */
541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </headers>
542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <libs>
544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* The list of paths to shared libraries and/or
545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 directories with shared libraries, one per line */
546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </libs>
547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          /* Optional sections */
549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_headers>
551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for header files to automatically
553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 generate include paths, one per line */
554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_headers>
555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <search_libs>
557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories to be searched
558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for shared libraries to resolve
559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 dependencies, one per line */
560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </search_libs>
561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <tools>
563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* List of directories with tools used
564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 for analysis (GCC toolchain), one per line */
565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </tools>
566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <cross_prefix>
568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* GCC toolchain prefix.
569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                 Examples:
570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-linux-gnueabi
571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                     arm-none-symbianelf */
572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </cross_prefix>
573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          <gcc_options>
575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              /* Additional GCC options, one per line */
576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          </gcc_options>
577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
57807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -sysinfo DIR
579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      This option may be used with -dump-system to dump ABI of operating
580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      systems and configure the dumping process.
581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          modules/Targets/{unix, symbian, windows}
583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
58407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -cmp-systems -d1 sys_dumps/NAME1/ARCH -d2 sys_dumps/NAME2/ARCH
585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Compare two system ABI dumps. Create compatibility reports for each
586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and the common HTML report including the summary of test
587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      results for all checked libraries. Report will be generated to:
58807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          sys_compat_reports/NAME1_to_NAME2/ARCH
589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
59007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -libs-list PATH
591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The file with a list of libraries, that should be dumped by
592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      the -dump-system option or should be checked by the -cmp-systems option.
593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -ext|-extended
595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      If your library A is supposed to be used by other library B and you
596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      want to control the ABI of B, then you should enable this option. The
597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      tool will check for changes in all data types, even if they are not
598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      used by any function in the library A. Such data types are not part
599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      of the A library ABI, but may be a part of the ABI of the B library.
600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The short scheme is:
602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        app C (broken) -> lib B (broken ABI) -> lib A (stable ABI)
603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -q|-quiet
605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print all messages to the file instead of stdout and stderr.
606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default path (can be changed by -log-path option):
607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          $COMMON_LOG_PATH
608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -stdout
610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Print analysis results (compatibility reports and ABI dumps) to stdout
611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      instead of creating a file. This would allow piping data to other programs.
612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-format FMT
614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change format of compatibility report.
615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Formats:
616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        htm - HTML format (default)
617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        xml - XML format
618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
61907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-format FMT
6205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Change format of ABI dump.
6215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Formats:
6225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        perl - Data::Dumper format (default)
6235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        xml - XML format
6245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
6251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -xml
6265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Alias for: --report-format=xml or --dump-format=xml
6271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
62807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -lang LANG
629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Set library language (C or C++). You can use this option if the tool
630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      cannot auto-detect a language. This option may be useful for checking
631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      C-library headers (--lang=C) in --headers-only or --extended modes.
632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -binary|-bin|-abi
6341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Binary\" compatibility problems only.
6351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
63607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
6371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
6381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko  -source|-src|-api
6391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Show \"Source\" compatibility problems only.
6401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Generate report to:
64107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
642f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6432489ef88760861175102e4508089608391beead3Andrey Ponomarenko  -limit-affected LIMIT
644f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      The maximum number of affected symbols listed under the description
645f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      of the changed type in the report.
6461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoOTHER OPTIONS:
648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test
649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Run internal tests. Create two binary incompatible versions of a sample
650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      library and run the tool to check them for compatibility. This option
651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      allows to check if the tool works correctly in the current environment.
652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -test-dump
654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Test ability to create, read and compare ABI dumps.
655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -debug
657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Debugging mode. Print debug info on the screen. Save intermediate
658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      analysis stages in the debug directory:
65907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          debug/LIB_NAME/VERSION/
660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Also consider using --dump option for debugging the tool.
6621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -cpp-compatible
66407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      If your header files are written in C language and can be compiled
66507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      by the G++ compiler (i.e. don't use C++ keywords), then you can tell
66607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      the tool about this and speedup the analysis.
667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
66807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -p|-params PATH
669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Path to file with the function parameter names. It can be used
670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for improving report view if the library header files have no
671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      parameter names. File format:
672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func1;param1;param2;param3 ...
674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            func2;param1;param2;param3 ...
675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko             ...
676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
67707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath PATH
67807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the XML-descriptor used
679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      for dumping the library ABI (see -dump option).
680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath1 PATH
68207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 1st XML-descriptor (-d1).
683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -relpath2 PATH
68507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Replace {RELPATH} macros to PATH in the 2nd XML-descriptor (-d2).
686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
68707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -dump-path PATH
6885c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko      Specify a *.abi.$AR_EXT or *.abi file path where to generate an ABI dump.
689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
69007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          abi_dumps/LIB_NAME/LIB_NAME_VERSION.abi.$AR_EXT
691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
69262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -sort
69362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Enable sorting of data in ABI dumps.
69462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
69507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -report-path PATH
6960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      Path to compatibility report.
6971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
69807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/compat_report.html
6991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
70007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -bin-report-path PATH
7011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Binary\" compatibility report.
702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
70307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/abi_compat_report.html
704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
70507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -src-report-path PATH
7061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Path to \"Source\" compatibility report.
7071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default:
70807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          compat_reports/LIB_NAME/V1_to_V2/src_compat_report.html
7091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
71007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log-path PATH
711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for all messages.
712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
71307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/VERSION/log.txt
714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
71507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log1-path PATH
716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 1st version of a library.
717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
71807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V1/log.txt
719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
72007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -log2-path PATH
721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Log path for 2nd version of a library.
722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
72307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko          logs/LIB_NAME/V2/log.txt
724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
72507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -logging-mode MODE
726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Change logging mode.
727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Modes:
728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        w - overwrite old logs (default)
729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        a - append old logs
730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        n - do not write any logs
731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  -list-affected
733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Generate file with the list of incompatible
734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      symbols beside the HTML compatibility report.
735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Use 'c++filt \@file' command from GNU binutils
736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      to unmangle C++ symbols in the generated file.
7371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Default names:
738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          abi_affected.txt
7391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko          src_affected.txt
740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -component NAME
742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      The component name in the title and summary of the HTML report.
743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      Default:
744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          library
745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
74607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -l-full|-lib-full NAME
74707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Change library name in the report title to NAME. By default
748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      will be displayed a name specified by -l option.
749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
75007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -b|-browse PROGRAM
7511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      Open report(s) in the browser (firefox, opera, etc.).
7521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
75362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  -open
75462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko      Open report(s) in the default browser.
75507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
75607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko  -extra-info DIR
75707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko      Dump extra info to DIR.
758570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
759570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -extra-dump
760570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Create extended ABI dump containing all symbols
761570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      from the translation unit.
762570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
763570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko  -force
764570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      Try to use this option if the tool doesn't work.
7658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerance LEVEL
7678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Apply a set of heuristics to successfully compile input
7688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      header files. You can enable several tolerance levels by
7698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      joining them into one string (e.g. 13, 124, etc.).
7708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Levels:
7718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          1 - skip non-Linux headers (e.g. win32_*.h, etc.)
7728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          2 - skip internal headers (e.g. *_p.h, impl/*.h, etc.)
7738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          3 - skip headers that iclude non-Linux headers
7748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          4 - skip headers included by others
7758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  -tolerant
7778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko      Enable highest tolerance level [1234].
778177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
779177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  -check
780177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      Check completeness of the ABI dump.
781e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
782e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko  -quick
783e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko      Quick analysis. Disable check of some template instances.
78462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT:
786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Compatibility report will be generated to:
78707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        compat_reports/LIB_NAME/V1_to_V2/compat_report.html
788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    Log will be generated to:
79007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V1/log.txt
79107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        logs/LIB_NAME/V2/log.txt
792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoEXIT CODES:
794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    0 - Compatible. The tool has run without any errors.
795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    non-zero - Incompatible or the tool has run with errors.
796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoREPORT BUGS TO:
7981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    Andrey Ponomarenko <aponomarenko\@rosalab.ru>
799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey PonomarenkoMORE INFORMATION:
801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ".$HomePage{"Wiki"}."
8021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ".$HomePage{"Dev1"}."\n");
803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $DescriptorTemplate = "
806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<?xml version=\"1.0\" encoding=\"utf-8\"?>
807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<descriptor>
808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko/* Primary sections */
810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<version>
812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* Version of the library */
813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</version>
814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<headers>
816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of paths to header files and/or
817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       directories with header files, one per line */
818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</headers>
819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<libs>
821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of paths to shared libraries (*.$LIB_EXT) and/or
822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       directories with shared libraries, one per line */
823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</libs>
824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko/* Optional sections */
826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<include_paths>
828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of include paths that will be provided
829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       to GCC to compile library headers, one per line.
830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       NOTE: If you define this section then the tool
831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       will not automatically generate include paths */
832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</include_paths>
833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<add_include_paths>
835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of include paths that will be added
836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       to the automatically generated include paths, one per line */
837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</add_include_paths>
838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_include_paths>
840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of include paths that will be removed from the
841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       list of automatically generated include paths, one per line */
842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_include_paths>
843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<gcc_options>
845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* Additional GCC options, one per line */
846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</gcc_options>
847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<include_preamble>
849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of header files that will be
85074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko       included before other headers, one per line  */
851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</include_preamble>
852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<defines>
854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of defines that will be added at the
855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       headers compiling stage, one per line:
856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #define A B
857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #define C D */
858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</defines>
859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
860a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko<add_namespaces>
861a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    /* The list of namespaces that should be added to the alanysis
862a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko       if the tool cannot find them automatically, one per line */
863a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko</add_namespaces>
864a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_types>
866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of data types, that
867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       should not be checked, one per line */
868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_types>
869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_symbols>
871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of functions (mangled/symbol names in C++),
872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       that should not be checked, one per line */
873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_symbols>
874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_namespaces>
876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of C++ namespaces, that
877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       should not be checked, one per line */
878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_namespaces>
879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_constants>
881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of constants that should
882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       not be checked, one name per line */
883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_constants>
884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_headers>
886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of header files and/or directories
887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       with header files that should not be checked, one per line */
888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_headers>
889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_libs>
891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of shared libraries and/or directories
892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       with shared libraries that should not be checked, one per line */
893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_libs>
894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<skip_including>
896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* The list of header files, that cannot be included
897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       directly (or non-self compiled ones), one per line */
898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</skip_including>
899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<search_headers>
901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* List of directories to be searched
902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       for header files to automatically
903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       generate include paths, one per line. */
904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</search_headers>
905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<search_libs>
907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* List of directories to be searched
908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       for shared librariess to resolve
909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       dependencies, one per line */
910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</search_libs>
911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<tools>
913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* List of directories with tools used
914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       for analysis (GCC toolchain), one per line */
915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</tools>
916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko<cross_prefix>
918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    /* GCC toolchain prefix.
919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko       Examples:
920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko           arm-linux-gnueabi
921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko           arm-none-symbianelf */
922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</cross_prefix>
923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko</descriptor>";
925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Operator_Indication = (
927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not" => "~",
928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assign" => "=",
929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "andassign" => "&=",
930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "orassign" => "|=",
931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xorassign" => "^=",
932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or" => "|",
933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "xor" => "^",
934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "addr" => "&",
935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and" => "&",
936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lnot" => "!",
937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "eq" => "==",
938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ne" => "!=",
939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lt" => "<",
940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshift" => "<<",
941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lshiftassign" => "<<=",
942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshiftassign" => ">>=",
943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "call" => "()",
944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mod" => "%",
945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "modassign" => "%=",
946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "subs" => "[]",
947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "land" => "&&",
948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lor" => "||",
949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rshift" => ">>",
950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ref" => "->",
951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "le" => "<=",
952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "deref" => "*",
953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mult" => "*",
954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "preinc" => "++",
955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => " delete",
956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecnew" => " new[]",
957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "vecdelete" => " delete[]",
958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "predec" => "--",
959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postinc" => "++",
960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "postdec" => "--",
961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plusassign" => "+=",
962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "plus" => "+",
963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minus" => "-",
964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "minusassign" => "-=",
965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gt" => ">",
966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ge" => ">=",
967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => " new",
968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "multassign" => "*=",
969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "divassign" => "/=",
970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "div" => "/",
971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "neg" => "-",
972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pos" => "+",
973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "memref" => "->*",
974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "compound" => "," );
975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
97662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %UnknownOperator;
97762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
97862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %NodeType= (
97962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "array_type" => "Array",
98062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "binfo" => "Other",
98162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "boolean_type" => "Intrinsic",
98262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "complex_type" => "Intrinsic",
98362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "const_decl" => "Other",
98462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "enumeral_type" => "Enum",
98562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "field_decl" => "Other",
98662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_decl" => "Other",
98762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "function_type" => "FunctionType",
98862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "identifier_node" => "Other",
98962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_cst" => "Other",
99062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "integer_type" => "Intrinsic",
991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "vector_type" => "Vector",
99262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "method_type" => "MethodType",
99362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "namespace_decl" => "Other",
99462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "parm_decl" => "Other",
99562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "pointer_type" => "Pointer",
99662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_cst" => "Other",
99762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "real_type" => "Intrinsic",
99862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "record_type" => "Struct",
99962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "reference_type" => "Ref",
100062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "string_cst" => "Other",
100162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "template_decl" => "Other",
1002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "template_type_parm" => "TemplateParam",
1003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "typename_type" => "TypeName",
1004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko  "sizeof_expr" => "SizeOf",
100562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_list" => "Other",
100662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "tree_vec" => "Other",
100762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "type_decl" => "Other",
100862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "union_type" => "Union",
100962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "var_decl" => "Other",
101062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "void_type" => "Intrinsic",
10118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "nop_expr" => "Other", #
10128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko  "addr_expr" => "Other", #
101362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "offset_type" => "Other" );
101462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_C = map {$_=>1} (
1016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++ 2003 keywords
1017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "public",
1018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "protected",
1019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "private",
1020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default",
1021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "template",
1022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new",
1023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"asm",
1024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dynamic_cast",
1025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "auto",
1026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "try",
1027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "namespace",
1028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typename",
1029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "using",
1030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "reinterpret_cast",
1031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "friend",
1032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "class",
1033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "virtual",
1034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "const_cast",
1035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mutable",
1036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_cast",
1037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "export",
1038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # C++0x keywords
1039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "noexcept",
1040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nullptr",
1041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "constexpr",
1042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "static_assert",
1043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "explicit",
1044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # cannot be used as a macro name
1045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # as it is an operator in C++
1046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "and",
1047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"and_eq",
1048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "not",
1049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"not_eq",
1050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "or"
1051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"or_eq",
1052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitand",
1053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"bitor",
1054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor",
1055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"xor_eq",
1056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #"compl"
1057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_F = map {$_=>1} (
1060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete",
1061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "catch",
1062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "alignof",
1063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "thread_local",
1064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "decltype",
1065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "typeid"
1066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_O = map {$_=>1} (
1069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool",
1070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "register",
1071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inline",
1072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "operator"
1073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CppKeywords_A = map {$_=>1} (
1076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "this",
10778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "throw",
10788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "template"
1079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoforeach (keys(%CppKeywords_C),
1082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_F),
1083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkokeys(%CppKeywords_O)) {
1084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CppKeywords_A{$_}=1;
1085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Header file extensions as described by gcc
1088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $HEADER_EXT = "h|hh|hp|hxx|hpp|h\\+\\+";
1089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IntrinsicMangling = (
1091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "void" => "v",
1092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bool" => "b",
1093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar_t" => "w",
1094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "char" => "c",
1095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signed char" => "a",
1096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned char" => "h",
1097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "short" => "s",
1098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned short" => "t",
1099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "int" => "i",
1100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int" => "j",
1101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long" => "l",
1102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long" => "m",
1103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long" => "x",
1104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int64" => "x",
1105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long" => "y",
1106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__int128" => "n",
1107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned __int128" => "o",
1108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "float" => "f",
1109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "double" => "d",
1110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long double" => "e",
1111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float80" => "e",
1112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "__float128" => "g",
1113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "..." => "z"
1114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1116177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %IntrinsicNames = map {$_=>1} keys(%IntrinsicMangling);
1117177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdcxxMangling = (
1119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std"=>"St",
1120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std9allocator"=>"Sa",
1121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_string"=>"Sb",
1122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std12basic_stringIcE"=>"Ss",
1123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_istreamIcE"=>"Si",
1124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std13basic_ostreamIcE"=>"So",
1125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "3std14basic_iostreamIcE"=>"Sd"
1126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1128e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkomy $DEFAULT_STD_PARMS = "std::(allocator|less|char_traits|regex_traits|istreambuf_iterator|ostreambuf_iterator)";
1129177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %DEFAULT_STD_ARGS = map {$_=>1} ("_Alloc", "_Compare", "_Traits", "_Rx_traits", "_InIter", "_OutIter");
1130177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1131177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy $ADD_TMPL_INSTANCES = 1;
1132f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $EMERGENCY_MODE_48 = 0;
113307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffix = (
1135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned int"=>"u",
1136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long"=>"l",
1137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long"=>"ul",
1138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "long long"=>"ll",
1139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unsigned long long"=>"ull"
1140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ConstantSuffixR =
1143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoreverse(%ConstantSuffix);
1144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OperatorMangling = (
1146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "~" => "co",
1147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "=" => "aS",
1148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|" => "or",
1149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^" => "eo",
1150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&" => "an",#ad (addr)
1151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "==" => "eq",
1152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!" => "nt",
1153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "!=" => "ne",
1154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<" => "lt",
1155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<=" => "le",
1156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<" => "ls",
1157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "<<=" => "lS",
1158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">" => "gt",
1159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">=" => "ge",
1160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>" => "rs",
1161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ">>=" => "rS",
1162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "()" => "cl",
1163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%" => "rm",
1164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "[]" => "ix",
1165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&&" => "aa",
1166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "||" => "oo",
1167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*" => "ml",#de (deref)
1168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "++" => "pp",#
1169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "--" => "mm",#
1170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new" => "nw",
1171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete" => "dl",
1172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "new[]" => "na",
1173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "delete[]" => "da",
1174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+=" => "pL",
1175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "+" => "pl",#ps (pos)
1176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-" => "mi",#ng (neg)
1177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "-=" => "mI",
1178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "*=" => "mL",
1179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/=" => "dV",
1180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "&=" => "aN",
1181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "|=" => "oR",
1182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "%=" => "rM",
1183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "^=" => "eO",
1184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/" => "dv",
1185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->*" => "pm",
1186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "->" => "pt",#rf (ref)
1187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "," => "cm",
1188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "?" => "qu",
1189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "." => "dt",
1190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sizeof"=> "sz"#st
1191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
119362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Intrinsic_Keywords = map {$_=>1} (
119462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "true",
119562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "false",
119662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Bool",
119762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "_Complex",
119862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "const",
119962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "int",
120062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "long",
120162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "void",
120262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "short",
120362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "float",
120462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "volatile",
120562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "restrict",
120662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "unsigned",
120762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "signed",
120862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "char",
120962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "double",
121062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "class",
121162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "struct",
121262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "union",
121362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    "enum"
121462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko);
121562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcHeader = map {$_=>1} (
1217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "aliases.h",
1218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argp.h",
1219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "argz.h",
1220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "assert.h",
1221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "cpio.h",
1222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ctype.h",
1223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "dirent.h",
1224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "envz.h",
1225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "errno.h",
1226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "error.h",
1227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "execinfo.h",
1228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fcntl.h",
1229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fstab.h",
1230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ftw.h",
1231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "glob.h",
1232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "grp.h",
1233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "iconv.h",
1234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ifaddrs.h",
1235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "inttypes.h",
1236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "langinfo.h",
1237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "limits.h",
1238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "link.h",
1239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "locale.h",
1240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "malloc.h",
1241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "math.h",
1242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "mntent.h",
1243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "monetary.h",
1244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nl_types.h",
1245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "obstack.h",
1246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "printf.h",
1247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "pwd.h",
1248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "regex.h",
1249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched.h",
1250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "search.h",
1251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "setjmp.h",
1252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "shadow.h",
1253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "signal.h",
1254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "spawn.h",
1255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdarg.h",
1256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdint.h",
1257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdio.h",
1258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stdlib.h",
1259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "string.h",
12609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "strings.h",
1261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tar.h",
1262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "termios.h",
1263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "time.h",
1264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ulimit.h",
1265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "unistd.h",
1266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "utime.h",
1267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wchar.h",
1268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wctype.h",
1269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wordexp.h" );
1270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %GlibcDir = map {$_=>1} (
1272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "arpa",
1273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "bits",
1274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "gnu",
1275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "netinet",
1276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "net",
1277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "nfs",
1278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc",
1279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sys",
1280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "linux" );
1281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %WinHeaders = map {$_=>1} (
12839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "dos.h",
12849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "process.h",
12859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock.h",
12869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config-win.h",
12879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "mem.h",
12889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "windows.h",
12899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "winsock2.h",
12909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "crtdbg.h",
12919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "ws2tcpip.h"
12929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
12939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
12949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ObsoleteHeaders = map {$_=>1} (
12959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "iostream.h",
12969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "fstream.h"
12979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
12989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
129974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %AlienHeaders = map {$_=>1} (
130074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Solaris
130174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "thread.h",
130274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h",
130374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # HPUX
130474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/stream.h",
130574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Symbian
130674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "AknDoc.h",
130774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Atari ST
130874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ext.h",
130974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "tos.h",
131074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # MS-DOS
131174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "alloc.h",
131274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko # Sparc
131374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sys/atomic.h"
131474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
131574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
13169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ConfHeaders = map {$_=>1} (
13179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "atomic",
13189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "conf.h",
13199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "config.h",
13209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "configure.h",
13219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "build.h",
13229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "setup.h"
13239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
13249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LocalIncludes = map {$_=>1} (
1326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local/include",
1327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "/usr/local" );
1328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OS_AddPath=(
1330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# These paths are needed if the tool cannot detect them automatically
1331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "macos"=>{
1332570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1333570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1334570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/include"
1335570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1336570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1337570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Library",
1338570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/lib"
1339570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1340570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1341570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/Developer/usr/bin"
1342570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    },
1344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "beos"=>{
1345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Haiku has GCC 2.95.3 by default
1346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to find GCC>=3.0 in /boot/develop/abi
1347570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "include"=>[
1348570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common",
1349570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop"
1350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1351570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "lib"=>[
1352570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/lib",
1353570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/lib",
1354570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/apps"
1355570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ],
1356570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        "bin"=>[
1357570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/common/bin",
1358570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/system/bin",
1359570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            "/boot/develop/abi"
1360570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        ]
1361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Slash_Type=(
1365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "default"=>"/",
1366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "windows"=>"\\"
1367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
1368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SLASH = $Slash_Type{$OSgroup}?$Slash_Type{$OSgroup}:$Slash_Type{"default"};
1370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Global Variables
1372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %COMMON_LANGUAGE=(
1373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  1 => "C",
1374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  2 => "C" );
1375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAX_COMMAND_LINE_ARGUMENTS = 4096;
13779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $MAX_CPPFILT_FILE_SIZE = 50000;
13789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy $CPPFILT_SUPPORT_FILE;
13799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy (%WORD_SIZE, %CPU_ARCH, %GCC_VERSION);
1381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $STDCXX_TESTING = 0;
1383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GLIBC_TESTING = 0;
13848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy $CPP_HEADERS = 0;
1385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckHeadersOnly = $CheckHeadersOnly_Opt;
1387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $CheckObjectsOnly = $CheckObjectsOnly_Opt;
13888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1389dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy $TargetComponent;
1390dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1391570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy $CheckUndefined = 0;
1392570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1393dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko# Set Target Component Name
1394dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoif($TargetComponent_Opt) {
1395dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $TargetComponent = lc($TargetComponent_Opt);
1396dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
1397dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkoelse
1398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # default: library
1399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # other components: header, system, ...
1400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TargetComponent = "library";
1401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $TOP_REF = "<a style='font-size:11px;' href='#Top'>to the top</a>";
14041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $SystemRoot;
1406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $MAIN_CPP_DIR;
14081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %RESULT;
1409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LOG_PATH;
1410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DEBUG_PATH;
1411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Cache;
1412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %LibInfo;
1413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $COMPILE_ERRORS = 0;
1414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompilerOptions;
1415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedDyLib;
1416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $TargetLibraryShortName = parse_libname($TargetLibraryName, "shortest", $OSgroup);
1417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Constants (#defines)
1419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Constants;
1420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipConstants;
142182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkomy %EnumConstants;
1422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
142374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko# Extra Info
142474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %SymbolHeader;
142574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %KnownLibs;
142674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1427177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Templates
1428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TemplateInstance;
1429177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %BasicTemplate;
1430177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateArg;
1431850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkomy %TemplateDecl;
1432177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TemplateMap;
1433177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1434177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko# Types
1435177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %TypeInfo;
1436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipTypes = (
1437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedTypes;
1440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TName_Tid;
1441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %EnumMembName_Id;
1442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %NestedNameSpaces = (
1443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualTable;
14461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VirtualTable_Model;
1447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable;
1448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassVTable_Content;
1449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VTableClass;
1450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AllocableClass;
1451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ClassMethods;
14521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %ClassNames;
1453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Class_SubClasses;
1454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %OverriddenMethods;
14554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %TypedefToAnon;
145662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy $MAX_ID = 0;
1457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkomy %CheckedTypeInfo;
1459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
1460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Typedefs
1461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_BaseName;
1462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Tr;
1463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Typedef_Eq;
1464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %StdCxxTypedef;
1465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MissedTypedef;
146662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase;
146762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %MissedBase_R;
14689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TypeTypedef;
1469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols
1471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolInfo;
1472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %tr_name;
1473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name_gcc;
1474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %mangled_name;
1475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipSymbols = (
1476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipNameSpaces = (
1479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1481a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenkomy %AddNameSpaces = (
1482a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "1"=>{},
1483a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko  "2"=>{} );
1484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList;
1485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %SkipSymbolsList;
1486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymbolsList_App;
1487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CheckedSymbols;
148862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Symbol_Library = (
148962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
149062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
149162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %Library_Symbol = (
149262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
149362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
149462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepSymbol_Library = (
149562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "1"=>{},
149662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko  "2"=>{} );
149762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %DepLibrary_Symbol = (
1498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MangledNames;
15019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %Func_ShortName;
1502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddIntParams;
1503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Interface_Impl;
150462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %GlobalDataObject;
150507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %WeakSymbols;
1506fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Library_Needed= (
1507fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "1"=>{},
1508fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  "2"=>{} );
1509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko# Extra Info
1511570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %UndefinedSymbols;
151274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %PreprocessedHeaders;
1513570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Headers
1515570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Preamble = (
1516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1517570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Registered_Headers;
1519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %Registered_Sources;
1520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %HeaderName_Paths;
1521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Dependency;
1522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Neighbors;
1523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Include_Paths = (
1524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1525570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %INC_PATH_AUTODETECT = (
1527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>1,
1528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>1 );
1529570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Add_Include_Paths = (
1530570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "1"=>[],
1531570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "2"=>[] );
1532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Skip_Include_Paths;
1533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RegisteredDirs;
1534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ErrorRedirect;
1535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Includes;
15368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %Header_Includes_R;
1537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_ShouldNotBeUsed;
1538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RecursiveIncludes;
1539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Header_Include_Prefix;
1540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeaders;
1541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipHeadersList=(
1542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SkipLibs;
1545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %Include_Order;
1546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TUnit_NameSpaces;
1547f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %TUnit_Classes;
15489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Funcs;
15499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %TUnit_Vars;
1550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
155107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %CppMode = (
1552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AutoPreambleMode = (
1555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
1557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %MinGWMode = (
1558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>0,
1559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>0 );
156001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %Cpp0xMode = (
156101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "1"=>0,
156201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko  "2"=>0 );
1563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Shared Objects
15659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObjects;
156607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkomy %RegisteredObjects_Short;
15679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredSONAMEs;
15689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %RegisteredObject_Dirs;
1569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Objects
1571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemObjects;
1572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultLibPaths;
15739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %DyLib_DefaultPath;
1574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System Headers
1576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SystemHeaders;
1577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultCppPaths;
1578570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultGccPaths;
1579570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultIncPaths;
1580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultCppHeader;
1581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %DefaultGccHeader;
1582570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @UsersIncPath;
1583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Merging
1585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompleteSignature;
1586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Version;
1587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt;
1588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt;
1589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %AddedInt_Virt;
1590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %RemovedInt_Virt;
1591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %VirtualReplacement;
1592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ChangedTypedef;
1593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatRules;
1594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %IncompleteRules;
1595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %UnknownRules;
15961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkomy %VTableChanged_M;
159762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkomy %ExtendedSymbols;
1598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ReturnedClass;
1599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %ParamClass;
16001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative;
16011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceAlternative_B;
16021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy %SourceReplacement;
1603f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkomy $CurrentSymbol; # for debugging
1604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1605f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko# Calling Conventions
1606f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkomy %UseConv_Real = (
1607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  1=>{ "R"=>0, "P"=>0 },
1608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko  2=>{ "R"=>0, "P"=>0 }
1609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko);
1610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko# ABI Dump
1612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkomy %UsedDump;
1613f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
1614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# OS Compliance
1615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetLibs;
1616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetHeaders;
1617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# OS Specifics
1619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $OStarget = $OSgroup;
1620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TargetTools;
1621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Compliance Report
1623dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkomy %Type_MaxSeverity;
1624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Recursion locks
1626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurLib;
1627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurTypes;
16288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy @RecurTypes_Diff;
1629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurInclude;
1630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy @RecurConstant;
1631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# System
1633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %SystemPaths = (
1634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "include"=>[],
1635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "lib"=>[],
1636570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "bin"=>[]
1637570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
1638570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy @DefaultBinPaths;
1639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $GCC_PATH;
1640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Symbols versioning
1642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %SymVer = (
1643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "1"=>{},
1644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  "2"=>{} );
1645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# Problem descriptions
1647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %CompatProblems;
16488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Constants;
16498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkomy %CompatProblems_Impl;
1650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TotalAffected;
1651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Reports
1653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentID = 1;
1654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart = "<span class=\"section\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Affected = "<span class=\"section_affected\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanStart_Info = "<span class=\"section_info\" onclick=\"javascript:showContent(this, 'CONTENT_ID')\">\n";
1657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentSpanEnd = "</span>\n";
1658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivStart = "<div id=\"CONTENT_ID\" style=\"display:none;\">\n";
1659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $ContentDivEnd = "</div>\n";
1660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy $Content_Counter = 0;
1661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko# Modes
16631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $JoinReport = 1;
16641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkomy $DoubleReport = 0;
1665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16662489ef88760861175102e4508089608391beead3Andrey Ponomarenkomy %Severity_Val=(
16672489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "High"=>3,
16682489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Medium"=>2,
16692489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Low"=>1,
16702489ef88760861175102e4508089608391beead3Andrey Ponomarenko    "Safe"=>-1
16712489ef88760861175102e4508089608391beead3Andrey Ponomarenko);
16722489ef88760861175102e4508089608391beead3Andrey Ponomarenko
1673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Modules()
1674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TOOL_DIR = get_dirname($0);
1676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TOOL_DIR)
1677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # patch for MS Windows
1678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TOOL_DIR = ".";
1679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SEARCH_DIRS = (
1681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # tool's directory
1682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR),
1683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # relative path to modules
1684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        abs_path($TOOL_DIR)."/../share/abi-compliance-checker",
168574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        # install path
168674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        'MODULES_INSTALL_PATH'
1687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
1688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $DIR (@SEARCH_DIRS)
1689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not is_abs($DIR))
1691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative path
1692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $DIR = abs_path($TOOL_DIR)."/".$DIR;
1693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $DIR."/modules") {
1695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $DIR."/modules";
1696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitStatus("Module_Error", "can't find modules");
1699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
170101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkomy %LoadedModules = ();
170201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub loadModule($)
1704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
170601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $LoadedModules{$Name}) {
170701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return;
170801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Name.pm";
1710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $Path) {
1711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    require $Path;
171401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $LoadedModules{$Name} = 1;
1715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1717570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub readModule($$)
1718570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
1719570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Module, $Name) = @_;
1720570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Path = $MODULES_DIR."/Internals/$Module/".$Name;
1721570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not -f $Path) {
1722570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Module_Error", "can't access \'$Path\'");
1723570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
1724570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return readFile($Path);
1725570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
1726570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
17270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showPos($)
1728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1729dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $Number = $_[0];
1730dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Number) {
1731dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = 1;
1732dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1733dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    else {
1734dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $Number = int($Number)+1;
1735dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
1736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Number>3) {
1737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number."th";
1738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==1) {
1740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "1st";
1741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==2) {
1743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "2nd";
1744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Number==3) {
1746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "3rd";
1747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Number;
1750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Tools($)
1754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Paths = keys(%TargetTools))
1758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (@Paths)
1760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-f join_P($Path, $Name)) {
176274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($Path, $Name);
1763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossPrefix)
1765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # user-defined prefix (arm-none-symbianelf, ...)
176674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $Candidate = join_P($Path, $CrossPrefix."-".$Name);
1767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
1769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub synch_Cmd($)
1779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GCC_PATH)
1782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC was not found yet
1783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
1784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Candidate = $GCC_PATH;
178662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Candidate=~s/\bgcc(|\.\w+)\Z/$Name$1/) {
1787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Candidate;
1788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
1790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath($)
1793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_CmdPath"}{$Name}) {
1797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_CmdPath"}{$Name};
1798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %BinUtils = map {$_=>1} (
1800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "c++filt",
1801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "objdump",
1802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "readelf"
1803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
180462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($BinUtils{$Name} and $GCC_PATH)
180562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($GCC_PATH)) {
1807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetTools{$Dir}=1;
1808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = search_Tools($Name);
1811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows") {
1812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Tools($Name.".exe");
1813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossPrefix)
1817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user-defined prefix
1818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = search_Cmd($CrossPrefix."-".$Name);
1819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $BinUtils{$Name})
1822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Candidate = synch_Cmd($Name))
1824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # synch with GCC
1825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Candidate=~/[\/\\]/)
18261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command path
1827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-f $Candidate) {
1828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path = $Candidate;
1829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Candidate = search_Cmd($Candidate))
18321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # command name
1833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Candidate;
1834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path) {
1838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = search_Cmd($Name);
1839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path and $OSgroup eq "windows")
18411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for *.exe file
1842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=search_Cmd($Name.".exe");
1843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\s/) {
1845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = "\"".$Path."\"";
1846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_CmdPath"}{$Name}=$Path);
1848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub search_Cmd($)
1851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
1853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Name);
1854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"search_Cmd"}{$Name}) {
1855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"search_Cmd"}{$Name};
1856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DefaultPath = get_CmdPath_Default($Name)) {
1858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Cache{"search_Cmd"}{$Name} = $DefaultPath);
1859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1860570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"bin"}})
1861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
186274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $CmdPath = join_P($Path,$Name);
1863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $CmdPath)
1864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name=~/gcc/) {
186662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(not check_gcc($CmdPath, "3"));
1867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"search_Cmd"}{$Name} = $CmdPath);
1869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"search_Cmd"}{$Name} = "");
1872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CmdPath_Default($)
1875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search in PATH
187662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $_[0]);
187762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_CmdPath_Default"}{$_[0]}) {
187862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_CmdPath_Default"}{$_[0]};
1879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
188062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_CmdPath_Default"}{$_[0]} = get_CmdPath_Default_I($_[0]));
188162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
188262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
188362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_CmdPath_Default_I($)
188462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # search in PATH
188562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Name = $_[0];
1886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/find/)
1887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # special case: search for "find" utility
1888a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`find \"$TMP_DIR\" -maxdepth 0 2>\"$TMP_DIR/null\"`) {
188962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "find";
1890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/gcc/) {
189362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return check_gcc($Name, "3");
1894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1895570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(checkCmd($Name)) {
189662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Name;
1897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
189862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($OSgroup eq "windows")
189962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1900a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(`$Name /? 2>\"$TMP_DIR/null\"`) {
190162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Name;
190262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1904570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultBinPaths)
1905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Name) {
190774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path, $Name);
1908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
191062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
1911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub classifyPath($)
1914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
1916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/[\*\[]/)
1917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # wildcard
1918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\*/.*/g;
1919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\\\\/g;
1920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Pattern");
1921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Path=~/[\/\\]/)
1923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory or relative path
1924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return (path_format($Path, $OSgroup), "Path");
1925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
1927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Path, "Name");
1928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
1930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readDescriptor($$)
1932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Content) = @_;
1934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion);
1935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DName = $DumpAPI?"descriptor":"descriptor \"d$LibVersion\"";
1936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Content) {
1937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "$DName is empty");
1938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content!~/\</) {
19405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        exitStatus("Error", "incorrect descriptor (see -d1 option)");
1941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\/\*(.|\n)+?\*\///g;
1943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/<\!--(.|\n)+?-->//g;
1944570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = parseTag(\$Content, "version");
1946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetVersion{$LibVersion}) {
1947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Version"} = $TargetVersion{$LibVersion};
1948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{$LibVersion}{"Version"}) {
1950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "version in the $DName is not specified (<version> section)");
1951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/{RELPATH}/)
1953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RelDir = $RelativeDirectory{$LibVersion}) {
1955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Content =~ s/{RELPATH}/$RelDir/g;
1956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
1958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NeedRelpath = $DumpAPI?"-relpath":"-relpath$LibVersion";
1960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "you have not specified $NeedRelpath option, but the $DName contains {RELPATH} macro");
1961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckObjectsOnly_Opt)
1965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DHeaders = parseTag(\$Content, "headers");
1967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DHeaders) {
1968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "header files in the $DName are not specified (<headers> section)");
1969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DHeaders) ne "none")
1971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor headers list
1972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Headers"})
1973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Headers"} .= "\n".$DHeaders;
1975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
1977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Headers"} = $DHeaders;
1978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DHeaders))
1980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
1982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
1983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckHeadersOnly_Opt)
1988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DObjects = parseTag(\$Content, "libs");
1990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DObjects) {
1991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries in the $DName are not specified (<libs> section)");
1992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(lc($DObjects) ne "none")
1994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # append the descriptor libraries list
1995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Descriptor{$LibVersion}{"Libs"})
1996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # multiple descriptors
1997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= "\n".$DObjects;
1998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
2000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{$LibVersion}{"Libs"} .= $DObjects;
2001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (split(/\s*\n\s*/, $DObjects))
2003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not -e $Path) {
2005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    exitStatus("Access_Error", "can't access \'$Path\'");
2006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_headers")))
2011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2017570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"include"}, $Path);
2018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "search_libs")))
2020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2026570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, $Path);
2027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "tools")))
2029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2035570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, $Path);
2036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetTools{$Path}=1;
2037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Prefix = parseTag(\$Content, "cross_prefix")) {
2039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CrossPrefix = $Prefix;
2040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2041570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"IncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"IncludePaths"}); # perl 5.8 doesn't support //=
2042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "include_paths")))
2043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2049570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"IncludePaths"}}, $Path);
2050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2051570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Descriptor{$LibVersion}{"AddIncludePaths"} = [] if(not defined $Descriptor{$LibVersion}{"AddIncludePaths"});
2052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "add_include_paths")))
2053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -d $Path) {
2055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access directory \'$Path\'");
2056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Path = get_abs_path($Path);
2058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
2059570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push(@{$Descriptor{$LibVersion}{"AddIncludePaths"}}, $Path);
2060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_include_paths")))
20628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip some auto-generated include paths
20638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not is_abs($Path))
20648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
20658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $P = abs_path($Path)) {
20668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Path = $P;
20678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
20688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
2069570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $Skip_Include_Paths{$LibVersion}{path_format($Path)} = 1;
2070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, parseTag(\$Content, "skip_including")))
20728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip direct including of some headers
2073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 2;
2075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"GccOptions"} = parseTag(\$Content, "gcc_options");
207774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    foreach my $Option (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"GccOptions"}))
207874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
20798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Option!~/\A\-(Wl|l|L)/)
20808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # skip linker options
208174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $CompilerOptions{$LibVersion} .= " ".$Option;
208274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipHeaders"} = parseTag(\$Content, "skip_headers");
2085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipHeaders"}))
2086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = 1;
2088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = 1;
2090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"SkipLibs"} = parseTag(\$Content, "skip_libs");
2092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"SkipLibs"}))
2093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipLibs{$LibVersion}{$Type}{$CPath} = 1;
2096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DDefines = parseTag(\$Content, "defines"))
2098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"Defines"})
2100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # multiple descriptors
2101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} .= "\n".$DDefines;
2102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
2104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"Defines"} = $DDefines;
2105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Order (split(/\s*\n\s*/, parseTag(\$Content, "include_order")))
2108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Order=~/\A(.+):(.+)\Z/) {
2110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Order{$LibVersion}{$1} = $2;
2111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (split(/\s*\n\s*/, parseTag(\$Content, "opaque_types")),
2114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_types")))
21151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # opaque_types renamed to skip_types (1.23.4)
2116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipTypes{$LibVersion}{$Type_Name} = 1;
2117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (split(/\s*\n\s*/, parseTag(\$Content, "skip_interfaces")),
2119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    split(/\s*\n\s*/, parseTag(\$Content, "skip_symbols")))
21201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # skip_interfaces renamed to skip_symbols (1.22.1)
2121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipSymbols{$LibVersion}{$Symbol} = 1;
2122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "skip_namespaces"))) {
2124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipNameSpaces{$LibVersion}{$NameSpace} = 1;
2125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2126a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $NameSpace (split(/\s*\n\s*/, parseTag(\$Content, "add_namespaces"))) {
2127a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $AddNameSpaces{$LibVersion}{$NameSpace} = 1;
2128a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
2129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (split(/\s*\n\s*/, parseTag(\$Content, "skip_constants"))) {
2130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SkipConstants{$LibVersion}{$Constant} = 1;
2131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $DIncPreamble = parseTag(\$Content, "include_preamble"))
2133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{$LibVersion}{"IncludePreamble"})
21351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # multiple descriptors
2136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} .= "\n".$DIncPreamble;
2137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
2139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Descriptor{$LibVersion}{"IncludePreamble"} = $DIncPreamble;
2140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
214401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub parseTag(@)
2145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
214601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $CodeRef = shift(@_);
214701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Tag = shift(@_);
214801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Tag or not $CodeRef) {
214901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return undef;
215001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
215101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Sp = 0;
215201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(@_) {
215301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Sp = shift(@_);
215401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
215501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Start = index(${$CodeRef}, "<$Tag>");
215601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Start!=-1)
2157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
215801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $End = index(${$CodeRef}, "</$Tag>");
215901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($End!=-1)
216001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
216101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $TS = length($Tag)+3;
216201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Content = substr(${$CodeRef}, $Start, $End-$Start+$TS, "");
216301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, 0, $TS-1, ""); # cut start tag
216401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            substr($Content, -$TS, $TS, ""); # cut end tag
216501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not $Sp)
216601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
216701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\A\s+//g;
216801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content=~s/\s+\Z//g;
216901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
217001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(substr($Content, 0, 1) ne "<") {
217101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Content = xmlSpecChars_R($Content);
217201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
217301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Content;
217401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
217601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return undef;
217701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
217801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
2179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getInfo($)
2180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2181850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2182850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $DumpPath or not -f $DumpPath);
2183850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2184850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    readTUDump($DumpPath);
2185850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing info
2187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTemplateParams_All();
21884b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
218974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
21904b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        setAnonTypedef_All();
21914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
21924b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getTypeInfo_All();
2194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    simplifyNames();
219582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    simplifyConstants();
2196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getVarInfo_All();
219701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    getSymbolInfo_All();
2198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2199850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %LibInfo = ();
2201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %TemplateInstance = ();
2202177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    %BasicTemplate = ();
2203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    %MangledNames = ();
2204850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %TemplateDecl = ();
2205850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %StdCxxTypedef = ();
2206850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %MissedTypedef = ();
2207850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Tr = ();
2208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Typedef_Eq = ();
22094b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    %TypedefToAnon = ();
2210850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
221162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clean cache
221262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeAttr"});
221362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    delete($Cache{"getTypeDeclId"});
221462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
221574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
2216570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
2217177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        remove_Unused($Version, "Extra");
221874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
221974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
222074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # remove unused types
2221570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($BinaryOnly and not $ExtendedCheck)
2222570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # --binary
2223177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "All");
2224570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
2225570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        else {
2226177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            remove_Unused($Version, "Extended");
2227177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2228177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2229177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2230177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckInfo)
2231177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2232177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$Version}})) {
2233177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($TypeInfo{$Version}{$Tid}, $Version);
2234177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2235177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2236177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (keys(%{$SymbolInfo{$Version}})) {
2237177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_Completeness($SymbolInfo{$Version}{$Sid}, $Version);
2238570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
223962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
224062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug) {
2242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # debugMangling($Version);
2243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2246850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub readTUDump($)
2247850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
2248850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $DumpPath = $_[0];
2249850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2250850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    open(TU_DUMP, $DumpPath);
2251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    local $/ = undef;
2252850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Content = <TU_DUMP>;
2253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    close(TU_DUMP);
2254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2255850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    unlink($DumpPath);
2256850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2257850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Content=~s/\n[ ]+/ /g;
2258850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Lines = split("\n", $Content);
2259850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2260850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2261850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef $Content;
2262850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2263177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $MAX_ID = $#Lines+1; # number of lines == number of nodes
2264850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2265850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (0 .. $#Lines)
2266850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
226762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Lines[$_]=~/\A\@(\d+)[ ]+([a-z_]+)[ ]+(.+)\Z/i)
2268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # get a number and attributes of a node
2269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next if(not $NodeType{$2});
2270850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info_type"}{$1}=$2;
2271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $LibInfo{$Version}{"info"}{$1}=$3;
2272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2273850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2274850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
2275850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($Lines[$_]);
2276850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2277850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
2278850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
2279850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    undef @Lines;
2280850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
2281850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
228282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenkosub simplifyConstants()
228382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko{
228482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
228582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
2286fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$Version}{$Constant}{"Header"})
2287fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
2288fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Value = $Constants{$Version}{$Constant}{"Value"};
2289fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $EnumConstants{$Version}{$Value}) {
2290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Constants{$Version}{$Constant}{"Value"} = $EnumConstants{$Version}{$Value}{"Value"};
2291fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
229282bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
229382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
229482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko}
229582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
2296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simplifyNames()
2297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Base (keys(%{$Typedef_Tr{$Version}}))
2299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2300f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Typedef_Eq{$Version}{$Base}) {
2301f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next;
2302f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2303f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my @Translations = sort keys(%{$Typedef_Tr{$Version}{$Base}});
2304f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($#Translations==0)
2305f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
2306f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(length($Translations[0])<=length($Base)) {
2307f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $Typedef_Eq{$Version}{$Base} = $Translations[0];
2308f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2309f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2310f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else
2311f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # select most appropriate
2312f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            foreach my $Tr (@Translations)
2313f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
2314f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Base=~/\A\Q$Tr\E/)
2315f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
2316f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $Typedef_Eq{$Version}{$Base} = $Tr;
2317f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    last;
2318f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
2319f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
2320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2322b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$Version}}))
2323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2324b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $TypeName = $TypeInfo{$Version}{$TypeId}{"Name"};
232562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TypeName) {
232662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
232762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
232862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        next if(index($TypeName,"<")==-1);# template instances only
232962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeName=~/>(::\w+)+\Z/)
233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip unused types
233162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next;
2332f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
233362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Base (sort {length($b)<=>length($a)}
233462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        sort {$b cmp $a} keys(%{$Typedef_Eq{$Version}}))
233562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
233662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(not $Base);
233762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(index($TypeName,$Base)==-1);
233862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if(length($TypeName) - length($Base) <= 3);
2339f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(my $Typedef = $Typedef_Eq{$Version}{$Base})
2340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2341f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\W|\Z)/$1$Typedef$2/g;
2342f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeName=~s/(\<|\,)\Q$Base\E(\w|\Z)/$1$Typedef $2/g;
2343f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(defined $TypeInfo{$Version}{$TypeId}{"TParam"})
2344850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
2345f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    foreach my $TPos (keys(%{$TypeInfo{$Version}{$TypeId}{"TParam"}}))
2346f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
2347f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(my $TPName = $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"})
2348f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
2349f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\W|\Z)/$Typedef$1/g;
2350f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $TPName=~s/\A\Q$Base\E(\w|\Z)/$Typedef $1/g;
23519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $TypeInfo{$Version}{$TypeId}{"TParam"}{$TPos}{"name"} = formatName($TPName, "T");
2352f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
2353f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
2354850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
2355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
23579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeName = formatName($TypeName, "T");
2358b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TypeInfo{$Version}{$TypeId}{"Name"} = $TypeName;
2359b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypeName} = $TypeId;
2360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
23634b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub setAnonTypedef_All()
23644b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko{
23654b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $InfoId (keys(%{$LibInfo{$Version}{"info"}}))
23664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
23674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$InfoId} eq "type_decl")
23684b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        {
23694b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(isAnon(getNameByInfo($InfoId))) {
23704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $TypedefToAnon{getTypeId($InfoId)} = 1;
23714b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
23724b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
23734b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
23744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko}
23754b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
2376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams_All()
2377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (keys(%{$LibInfo{$Version}{"info"}}))
2379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "template_decl") {
2381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setTemplateParams($_);
2382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTemplateParams($)
2387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2388177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tid = getTypeId($_[0]);
2389989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
2390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2391989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/(inst|spcs)[ ]*:[ ]*@(\d+) /)
2392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
239362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TmplInst_Id = $2;
2394177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            setTemplateInstParams($_[0], $TmplInst_Id);
239562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            while($TmplInst_Id = getNextElem($TmplInst_Id)) {
2396177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                setTemplateInstParams($_[0], $TmplInst_Id);
2397177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2398177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2399177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2400177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $BasicTemplate{$Version}{$Tid} = $_[0];
2401177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2402177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Prms = getTreeAttr_Prms($_[0]))
2403177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2404177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Valu = getTreeAttr_Valu($Prms))
2405177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2406177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Vector = getTreeVec($Valu);
2407177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Vector}))
2408177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2409177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Val = getTreeAttr_Valu($Vector->{$Pos}))
2410177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2411177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Name = getNameByInfo($Val))
2412177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2413177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TemplateArg{$Version}{$_[0]}{$Pos} = $Name;
2414177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if($LibInfo{$Version}{"info_type"}{$Val} eq "parm_decl") {
2415177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = $Val;
2416177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2417177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            else {
2418177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TemplateInstance{$Version}{"Type"}{$Tid}{$Pos} = getTreeAttr_Type($Val);
2419177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2420177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2421177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2422177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2423989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
2424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
242662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $TypeId = getTreeAttr_Type($_[0]))
2427850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
2428850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $IType = $LibInfo{$Version}{"info_type"}{$TypeId})
2429850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
2430850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($IType eq "record_type") {
2431177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TemplateDecl{$Version}{$TypeId} = 1;
2432850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2433850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2434850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
2435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2437177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub setTemplateInstParams($$)
2438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2439177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tmpl, $Inst) = @_;
2440177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2441177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$Inst})
2442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2443989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my ($Params_InfoId, $ElemId) = ();
2444989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
2445989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $Params_InfoId = $1;
2446989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2447989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
2448989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $ElemId = $1;
2449989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2450989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Params_InfoId and $ElemId)
2451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2452989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Params_Info = $LibInfo{$Version}{"info"}{$Params_InfoId};
2453989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($Params_Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
2454989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2455989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my ($PPos, $PTypeId) = ($1, $2);
2456989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if(my $PType = $LibInfo{$Version}{"info_type"}{$PTypeId})
2457989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
2458177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($PType eq "template_type_parm") {
2459177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateDecl{$Version}{$ElemId} = 1;
2460989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
2461989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2462850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($LibInfo{$Version}{"info_type"}{$ElemId} eq "function_decl")
2463850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # functions
246462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Func"}{$ElemId}{$PPos} = $PTypeId;
2465177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2466989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2467850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else
2468850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # types
246962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TemplateInstance{$Version}{"Type"}{$ElemId}{$PPos} = $PTypeId;
2470177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $BasicTemplate{$Version}{$ElemId} = $Tmpl;
2471989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeDeclId($)
2478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
247962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0])
2480dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
248162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $Cache{"getTypeDeclId"}{$Version}{$_[0]}) {
248262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Cache{"getTypeDeclId"}{$Version}{$_[0]};
248362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
248462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
248562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
248662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+)/) {
248762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = $1);
248862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2489dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
2490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
249162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"getTypeDeclId"}{$Version}{$_[0]} = 0);
2492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeInfo_All()
2495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
249662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # missed typedefs: QStyle::State is typedef to QFlags<QStyle::StateFlag>
2499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # but QStyleOption.state is of type QFlags<QStyle::StateFlag> in the TU dump
2500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: check GCC versions
2501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Pre();
2502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
250362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
25050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # forward order only
2506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IType = $LibInfo{$Version}{"info_type"}{$_};
2507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($IType=~/_type\Z/ and $IType ne "function_type"
2508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $IType ne "method_type") {
250962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getTypeInfo("$_");
2510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
251262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
251362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # add "..." type
251401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TypeInfo{$Version}{"-1"} = {
251562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Name" => "...",
251662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "Type" => "Intrinsic",
251701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        "Tid" => "-1"
251862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    };
251901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TName_Tid{$Version}{"..."} = "-1";
252062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
252162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not check_gcc($GCC_PATH, "4.5"))
2522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC < 4.5
2523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addMissedTypes_Post();
2524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2525177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2526177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
2527177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2528177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
2529177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}}))
2530177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2531177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Tid}
2532177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not defined $TypeInfo{$Version}{$Tid}{"Template"})
2533177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2534177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Memb"})
2535177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2536177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Memb"}}))
2537177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2538177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"})
2539177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2540177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            if(my %MAttr = getTypeAttr($MembTypeId))
2541177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            {
2542177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"algn"} = $MAttr{"Algn"};
2543177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                                $MembTypeId = $TypeInfo{$Version}{$Tid}{"Memb"}{$Pos}{"type"} = instType($TemplateMap{$Version}{$Tid}, $MembTypeId, $Version);
2544177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            }
2545177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2546177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2547177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2548177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$Version}{$Tid}{"Base"})
2549177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2550177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach my $Bid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$Version}{$Tid}{"Base"}}))
2551177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
2552177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $NBid = instType($TemplateMap{$Version}{$Tid}, $Bid, $Version);
2553177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2554177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($NBid ne $Bid)
2555177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        {
2556177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            %{$TypeInfo{$Version}{$Tid}{"Base"}{$NBid}} = %{$TypeInfo{$Version}{$Tid}{"Base"}{$Bid}};
2557177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            delete($TypeInfo{$Version}{$Tid}{"Base"}{$Bid});
2558177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
2559177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
2560177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2561177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2562177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2563177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2565177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2566177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub createType($$)
2567177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
2568177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Attr, $LibVersion) = @_;
2569177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $NewId = ++$MAX_ID;
2570177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2571082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko    $Attr->{"Tid"} = $NewId;
2572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $TypeInfo{$Version}{$NewId} = $Attr;
2573e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $TName_Tid{$Version}{formatName($Attr->{"Name"}, "T")} = $NewId;
2574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "$NewId";
2576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
2577177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub instType($$$)
2579177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{ # create template instances
2580177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Map, $Tid, $LibVersion) = @_;
2581be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko
2582be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    if(not $TypeInfo{$LibVersion}{$Tid}) {
2583be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko        return undef;
2584be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko    }
2585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Attr = dclone($TypeInfo{$LibVersion}{$Tid});
2586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Key (sort keys(%{$Map}))
2588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2589177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Val = $Map->{$Key})
2590177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2591177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/\b$Key\b/$Val/g;
2592177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2593177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2594177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/\b$Key\b/$Val/g;
2595177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2596177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}})) {
2597177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"TParam"}{$_}{"name"}=~s/\b$Key\b/$Val/g;
2598177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2599177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2600177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
2601177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # remove absent
2602177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko          # _Traits, etc.
2603177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $Attr->{"Name"}=~s/,\s*\b$Key(,|>)/$1/g;
2604e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(defined $Attr->{"NameSpace"}) {
2605177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Attr->{"NameSpace"}=~s/,\s*\b$Key(,|>)/$1/g;
2606177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2607177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (keys(%{$Attr->{"TParam"}}))
2608177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Attr->{"TParam"}{$_}{"name"} eq $Key) {
2610177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($Attr->{"TParam"}{$_});
2611177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2612e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                else {
2613177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Attr->{"TParam"}{$_}{"name"}=~s/,\s*\b$Key(,|>)/$1/g;
2614177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2616177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2618177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2619177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = 0;
2620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2621177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Attr->{"TParam"})
2622177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2623177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (sort {int($a)<=>int($b)} keys(%{$Attr->{"TParam"}}))
2624177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2625177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $PName = $Attr->{"TParam"}{$_}{"name"};
2626177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2627177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $PTid = $TName_Tid{$LibVersion}{$PName})
2628177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2629177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Base = get_BaseType($PTid, $LibVersion);
2630177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2631177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Base{"Type"} eq "TemplateParam"
2632177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or defined $Base{"Template"})
2633177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2634177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Tmpl = 1;
2635177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last
2636177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2637177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2638177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2639177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2640177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2641177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Id = getTypeIdByName($Attr->{"Name"}, $LibVersion)) {
2642177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return "$Id";
2643177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2644177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else
2645177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2646177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $Tmpl) {
2647177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($Attr->{"Template"});
2648177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2649177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2650e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my $New = createType($Attr, $LibVersion);
2651e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
2652177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %EMap = ();
2653177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(defined $TemplateMap{$LibVersion}{$Tid}) {
2654177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %EMap = %{$TemplateMap{$LibVersion}{$Tid}};
2655177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2656177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Map})) {
2657177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $EMap{$_} = $Map->{$_};
2658177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2659177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2660e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"BaseType"}) {
2661e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"BaseType"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"BaseType"}, $LibVersion);
2662177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2663e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Base"})
2664177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2665e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$New}{"Base"}}))
2666177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
2667177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NBid = instType(\%EMap, $Bid, $LibVersion);
2668177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2669177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($NBid ne $Bid)
2670177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
2671e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$New}{"Base"}{$NBid}} = %{$TypeInfo{$LibVersion}{$New}{"Base"}{$Bid}};
2672e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    delete($TypeInfo{$LibVersion}{$New}{"Base"}{$Bid});
2673177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
2674177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2675177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2676177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2677e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Memb"})
2678177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2679be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Memb"}}))
2680be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko            {
2681be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}) {
2682be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Memb"}{$_}{"type"}, $LibVersion);
2683be558b873e36f8e28994af8fdacb08cf43b778f3Andrey Ponomarenko                }
2684177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2685177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2686177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2687e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Param"})
2688177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
2689e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}{$New}{"Param"}})) {
2690e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Param"}{$_}{"type"}, $LibVersion);
2691177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
2692177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2693177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2694e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$New}{"Return"}) {
2695e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $TypeInfo{$LibVersion}{$New}{"Return"} = instType(\%EMap, $TypeInfo{$LibVersion}{$New}{"Return"}, $LibVersion);
2696177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2697177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2698e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        return $New;
2699177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Pre()
2703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
270462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %MissedTypes = ();
2705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MissedTDid (sort {int($a)<=>int($b)} keys(%{$LibInfo{$Version}{"info"}}))
2706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detecting missed typedefs
2707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$MissedTDid} eq "type_decl")
2708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
270962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeId = getTreeAttr_Type($MissedTDid);
2710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypeId);
271162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TypeType = getTypeType($TypeId);
2712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeType eq "Unknown")
2713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # template_type_parm
2714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypeDeclId = getTypeDeclId($TypeId);
2717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypeDeclId eq $MissedTDid);#or not $TypeDeclId
2718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TypedefName = getNameByInfo($MissedTDid);
2719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TypedefName);
2720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($TypedefName eq "__float80");
2721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(isAnon($TypedefName));
2722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TypeDeclId
2723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or getNameByInfo($TypeDeclId) ne $TypedefName) {
272462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MissedTypes{$Version}{$TypeId}{$MissedTDid} = 1;
2725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2728b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my %AddTypes = ();
272962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$MissedTypes{$Version}}))
2730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add missed typedefs
273162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Missed = keys(%{$MissedTypes{$Version}{$Tid}});
2732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Missed or $#Missed>=1) {
2733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MissedTDid = $Missed[0];
2736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypedefName, $TypedefNS) = getTrivialName($MissedTDid, $Tid);
2737b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $TypedefName) {
2738b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            next;
2739b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        }
2740177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $NewId = ++$MAX_ID;
2741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MissedInfo = ( # typedef info
2742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Name" => $TypedefName,
2743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "NameSpace" => $TypedefNS,
2744fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            "BaseType" => $Tid,
2745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "Type" => "Typedef",
2746177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            "Tid" => "$NewId" );
2747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($H, $L) = getLocation($MissedTDid);
2748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Header"} = $H;
2749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedInfo{"Line"} = $L;
2750b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/\*|\&|\s/)
2751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # other types
2752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2754b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($TypedefName=~/>(::\w+)+\Z/)
2755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # QFlags<Qt::DropAction>::enum_type
2756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
2757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
275862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(getTypeType($Tid)=~/\A(Intrinsic|Union|Struct|Enum|Class)\Z/)
2759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # double-check for the name of typedef
276062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my ($TName, $TNS) = getTrivialName(getTypeDeclId($Tid), $Tid); # base type info
2761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $TName);
2762b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(length($TypedefName)>=length($TName))
2763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too long typedef
2764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2766b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TName=~/\A\Q$TypedefName\E</) {
2767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2769b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($TypedefName=~/\A\Q$TName\E/)
2770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # QDateTimeEdit::Section and QDateTimeEdit::Sections::enum_type
2771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2773b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(get_depth($TypedefName)==0 and get_depth($TName)!=0)
2774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # std::_Vector_base and std::vector::_Base
2775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
2776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2778b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2779b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $AddTypes{$MissedInfo{"Tid"}} = \%MissedInfo;
2780b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # register typedef
2782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"Tid"} = $MissedInfo{"Tid"};
278362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $MissedTypedef{$Version}{$Tid}{"TDid"} = $MissedTDid;
2784b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        $TName_Tid{$Version}{$TypedefName} = $MissedInfo{"Tid"};
2785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2786b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
2787b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    # add missed & remove other
2788b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    $TypeInfo{$Version} = \%AddTypes;
2789b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    delete($Cache{"getTypeAttr"}{$Version});
2790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMissedTypes_Post()
2793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (keys(%{$MissedTypedef{$Version}}))
2795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
279662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Tid = $MissedTypedef{$Version}{$BaseId}{"Tid"})
279762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
279862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$Version}{$Tid}{"Size"} = $TypeInfo{$Version}{$BaseId}{"Size"};
279962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $TName = $TypeInfo{$Version}{$Tid}{"Name"}) {
280062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Typedef_BaseName{$Version}{$TName} = $TypeInfo{$Version}{$BaseId}{"Name"};
280162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
280262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
280662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeInfo($)
2807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2808b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TypeId = $_[0];
2809b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    %{$TypeInfo{$Version}{$TypeId}} = getTypeAttr($TypeId);
2810b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    my $TName = $TypeInfo{$Version}{$TypeId}{"Name"};
2811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TName) {
2812b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        delete($TypeInfo{$Version}{$TypeId});
2813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArraySize($$)
2817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $BaseName) = @_;
281962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Size = getSize($TypeId))
2820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
282162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Elems = $Size/$BYTE_SIZE;
282262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($BaseName=~s/\s*\[(\d+)\]//) {
282362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Elems/=$1;
2824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
282562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BasicId = $TName_Tid{$Version}{$BaseName})
282662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
282762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $BasicSize = $TypeInfo{$Version}{$BasicId}{"Size"}) {
282862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Elems/=$BasicSize;
282962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
283162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Elems;
2832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
283362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
2834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTParams($$)
2837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
283862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $Kind) = @_;
283962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @TmplParams = ();
284062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @Positions = sort {int($a)<=>int($b)} keys(%{$TemplateInstance{$Version}{$Kind}{$TypeId}});
284162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (@Positions)
2842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
284362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Param_TypeId = $TemplateInstance{$Version}{$Kind}{$TypeId}{$Pos};
284462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $NodeType = $LibInfo{$Version}{"info_type"}{$Param_TypeId};
284562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $NodeType)
284662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # typename_type
2847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
2848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
284962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($NodeType eq "tree_vec")
285062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
285162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Pos!=$#Positions)
285262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # select last vector of parameters ( ns<P1>::type<P2> )
285362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next;
285462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
285562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
285662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = get_TemplateParam($Pos, $Param_TypeId);
285762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P (@Params)
285862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
285962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P eq "") {
286062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
286162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
286262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            elsif($P ne "\@skip\@") {
286362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @TmplParams = (@TmplParams, $P);
286462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
286762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return @TmplParams;
2868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
2869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
287062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeAttr($)
2871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
287262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
28730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my %TypeAttr = ();
287462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TypeInfo{$Version}{$TypeId}
287562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $TypeInfo{$Version}{$TypeId}{"Name"})
287662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # already created
287762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$TypeInfo{$Version}{$TypeId}};
2878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
287962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($Cache{"getTypeAttr"}{$Version}{$TypeId})
288062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incomplete type
288162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ();
288262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
288362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"getTypeAttr"}{$Version}{$TypeId} = 1;
288462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
288562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
2886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
288762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
288862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $MissedBase{$Version}{$TypeId} and isTypedef($TypeId))
288962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
289062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
289162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
289262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Info=~/qual[ ]*:/)
289362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2894177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $NewId = ++$MAX_ID;
2895177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase{$Version}{$TypeId} = "$NewId";
2897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $MissedBase_R{$Version}{$NewId} = $TypeId;
2898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info"}{$NewId} = $LibInfo{$Version}{"info"}{$TypeId};
2899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $LibInfo{$Version}{"info_type"}{$NewId} = $LibInfo{$Version}{"info_type"}{$TypeId};
290062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
290162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
290262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = "Typedef";
290362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
290462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
290562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TypeAttr{"Type"} = getTypeType($TypeId);
290662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
290762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2908177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $ScopeId = getTreeAttr_Scpe($TypeDeclId))
2909177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
2910177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$ScopeId} eq "function_decl")
2911177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # local code
2912177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
2913177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
2914177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
2915177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Unknown") {
2917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
2918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"}=~/(Func|Method|Field)Ptr/)
2920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
292162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getMemPtrAttr(pointTo($TypeId), $TypeId, $TypeAttr{"Type"});
2922989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(my $TName = $TypeAttr{"Name"})
2923989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
292462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2925989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TName} = $TypeId;
2926989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2927989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2928989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        else {
2929989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return ();
2930989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
2931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeAttr{"Type"} eq "Array")
2933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
293462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
293562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
29360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
29370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2938f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
2939f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
2940f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
2941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
294262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my %BTAttr = getTypeAttr($BTid))
2943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
294462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $BTAttr{"Name"}) {
294562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
294662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
29470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $NElems = getArraySize($TypeId, $BTAttr{"Name"}))
2948989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
294962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Size = getSize($TypeId)) {
295062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeAttr{"Size"} = $Size/$BYTE_SIZE;
295162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
29520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2953989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[$NElems]".$2;
2954989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2955989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
29560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[$NElems]";
2957989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2959989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
2960989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
2961989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version}; # pointer
29620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($BTAttr{"Name"}=~/\A([^\[\]]+)(\[(\d+|)\].*)\Z/) {
2963989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $TypeAttr{"Name"} = $1."[]".$2;
2964989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2965989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
29660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TypeAttr{"Name"} = $BTAttr{"Name"}."[]";
2967989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
2968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
29699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
29700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BTAttr{"Header"})  {
29710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Header"} = $BTAttr{"Header"};
2972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
297362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2974989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
2975989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return %TypeAttr;
2976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
29770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return ();
2978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2979177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/\A(Intrinsic|Union|Struct|Enum|Class|Vector)\Z/)
2980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
298162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
29820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"})
29830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
298462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
2985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $IntrinsicNames{$TypeAttr{"Name"}}
2987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or getTypeDeclId($TypeAttr{"Tid"}))
29880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # NOTE: register only one int: with built-in decl
29890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
29900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
29910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
29920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
29930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return %TypeAttr;
29940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
29950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
29960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
29970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
2998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"}=~/TemplateParam|TypeName/)
3000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3001177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        %TypeAttr = getTrivialTypeAttr($TypeId);
3002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
3003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3004177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
3005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
3009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
3011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
3012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($TypeAttr{"Type"} eq "SizeOf")
3015177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3016177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"BaseType"} = getTreeAttr_Type($TypeId);
3017177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
3018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Name"} = "sizeof(".$BTAttr{"Name"}.")";
3019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TypeAttr{"Name"})
3020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
3022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return %TypeAttr;
3023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else {
3025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return ();
3026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3029989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # derived types
303062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my ($BTid, $BTSpec) = selectBaseType($TypeId);
303162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $BTid) {
30320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return ();
30330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TypeAttr{"BaseType"} = $BTid;
303562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$BTid})
3036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
303762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $MissedTDid = $MissedTypedef{$Version}{$BTid}{"TDid"})
3038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
303962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($MissedTDid ne $TypeDeclId) {
3040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeAttr{"BaseType"} = $MissedTypedef{$Version}{$BTid}{"Tid"};
304162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
3042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %BTAttr = getTypeAttr($TypeAttr{"BaseType"});
30450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $BTAttr{"Name"})
304662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # templates
3047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
3048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
30490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTAttr{"Type"} eq "Typedef")
3050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relinking typedefs
3051fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %BaseBase = get_Type($BTAttr{"BaseType"}, $Version);
305262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($BTAttr{"Name"} eq $BaseBase{"Name"}) {
3053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TypeAttr{"BaseType"} = $BaseBase{"Tid"};
3054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
30560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($BTSpec)
3057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer"
30590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BTAttr{"Name"}=~/\([\*]+\)/)
3060989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
30610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"};
3062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Name"}=~s/\(([*]+)\)/($1*)/g;
3063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
30650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Name"} = $BTAttr{"Name"}." ".$BTSpec;
3066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
30690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Name"} = $BTAttr{"Name"};
3070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TypeAttr{"Type"} eq "Typedef")
3072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Name"} = getNameByInfo($TypeDeclId);
307474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
307574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(index($TypeAttr{"Name"}, "tmp_add_type")==0) {
307674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return ();
307774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
307874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3079850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(isAnon($TypeAttr{"Name"}))
3080850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # anon typedef to anon type: ._N
3081850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return ();
3082850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
30838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
30848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$TypeDeclId}=~/ artificial /i)
30858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # artificial typedef of "struct X" to "X"
30868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeAttr{"Artificial"} = 1;
30878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
30888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
3089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $NS = getNameSpace($TypeDeclId))
3090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $TypeName = $TypeAttr{"Name"};
3092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NS=~/\A(struct |union |class |)((.+)::|)\Q$TypeName\E\Z/)
3093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # "some_type" is the typedef to "struct some_type" in C++
3094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($3) {
3095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TypeAttr{"Name"} = $3."::".$TypeName;
3096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
3099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
3100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"NameSpace"} = $NS;
3101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3102989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
3103989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($TypeAttr{"NameSpace"}=~/\Astd(::|\Z)/
3104989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    and $TypeAttr{"Name"}!~/>(::\w+)+\Z/)
3105989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
31060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($BTAttr{"NameSpace"}
31070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        and $BTAttr{"NameSpace"}=~/\Astd(::|\Z)/ and $BTAttr{"Name"}=~/</)
3108989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        { # types like "std::fpos<__mbstate_t>" are
3109989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # not covered by typedefs in the TU dump
3110989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                          # so trying to add such typedefs manually
31110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $StdCxxTypedef{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
31120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if(length($TypeAttr{"Name"})<=length($BTAttr{"Name"}))
3113989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                            {
31140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/))
3115989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                { # skip "other" in "std" and "type" in "boost"
31160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                    $Typedef_Eq{$Version}{$BTAttr{"Name"}} = $TypeAttr{"Name"};
3117989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                                }
3118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
3119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
3120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
31238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TypeAttr{"Name"} ne $BTAttr{"Name"} and not $TypeAttr{"Artificial"}
31240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $TypeAttr{"Name"}!~/>(::\w+)+\Z/ and $BTAttr{"Name"}!~/>(::\w+)+\Z/)
3125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
31260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(not defined $Typedef_BaseName{$Version}{$TypeAttr{"Name"}})
31270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # typedef int*const TYPEDEF; // first
31280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # int foo(TYPEDEF p); // const is optimized out
31290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Typedef_BaseName{$Version}{$TypeAttr{"Name"}} = $BTAttr{"Name"};
31300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if($BTAttr{"Name"}=~/</)
31310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
31320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(($BTAttr{"Name"}!~/\A(std|boost)::/ or $TypeAttr{"Name"}!~/\A[a-z]+\Z/)) {
31330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Typedef_Tr{$Version}{$BTAttr{"Name"}}{$TypeAttr{"Name"}} = 1;
31340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
3135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
3136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeDeclId);
3139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TypeAttr{"Size"})
3141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TypeAttr{"Type"} eq "Pointer") {
3143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr{"Size"} = $WORD_SIZE{$Version};
3144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
31450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($BTAttr{"Size"}) {
31460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr{"Size"} = $BTAttr{"Size"};
3147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3149f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Algn = getAlgn($TypeId)) {
3150f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3151f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
31529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
31530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(not $TypeAttr{"Header"} and $BTAttr{"Header"})  {
31540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr{"Header"} = $BTAttr{"Header"};
3155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
315662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        %{$TypeInfo{$Version}{$TypeId}} = %TypeAttr;
31570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeAttr{"Name"} ne $BTAttr{"Name"})
3158989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # typedef to "class Class"
3159989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko          # should not be registered in TName_Tid
3160989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $TName_Tid{$Version}{$TypeAttr{"Name"}}) {
3161989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                $TName_Tid{$Version}{$TypeAttr{"Name"}} = $TypeId;
3162989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
3163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return %TypeAttr;
3165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
316862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeVec($)
316962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
317062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Vector = ();
317162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
317262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
317362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($Info=~s/ (\d+)[ ]*:[ ]*\@(\d+) / /)
317462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # string length is N-1 because of the null terminator
317562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Vector{$1} = $2;
317662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
317762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
317862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return \%Vector;
317962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
318062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TemplateParam($$)
3182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $Type_Id) = @_;
318462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $Type_Id);
318562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $NodeType = $LibInfo{$Version}{"info_type"}{$Type_Id};
318662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $NodeType);
318762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($NodeType eq "integer_cst")
3188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # int (1), unsigned (2u), char ('c' as 99), ...
318962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $CstTid = getTreeAttr_Type($Type_Id);
3190b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my %CstType = getTypeAttr($CstTid); # without recursion
3191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = getNodeIntCst($Type_Id);
3192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $CstSuffix = $ConstantSuffix{$CstType{"Name"}}) {
319362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Num.$CstSuffix);
3194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
319662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("(".$CstType{"Name"}.")".$Num);
3197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
319962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "string_cst") {
320062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getNodeStrCst($Type_Id));
3201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
320262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($NodeType eq "tree_vec")
320362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
320462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Vector = getTreeVec($Type_Id);
320562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my @Params = ();
320662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $P1 (sort {int($a)<=>int($b)} keys(%{$Vector}))
320762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
320862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $P2 (get_TemplateParam($Pos, $Vector->{$P1})) {
320962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@Params, $P2);
321062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
321162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
321262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return @Params;
3213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3214177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    elsif($NodeType eq "parm_decl")
3215177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3216177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        (getNameByInfo($Type_Id));
3217177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
322062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ParamAttr = getTypeAttr($Type_Id);
3221b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        my $PName = $ParamAttr{"Name"};
3222b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if(not $PName) {
322362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ();
3224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3225b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        if($PName=~/\>/)
3226b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        {
3227b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(my $Cover = cover_stdcxx_typedef($PName)) {
3228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PName = $Cover;
3229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Pos>=1 and
32321477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        $PName=~/\A$DEFAULT_STD_PARMS\</)
3233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # template<typename _Tp, typename _Alloc = std::allocator<_Tp> >
3234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Key, typename _Compare = std::less<_Key>
3235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _Traits = std::char_traits<_CharT> >
3236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _Ch_type, typename _Rx_traits = regex_traits<_Ch_type> >
3237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _InIter = istreambuf_iterator<_CharT> >
3238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # template<typename _CharT, typename _OutIter = ostreambuf_iterator<_CharT> >
323962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ("\@skip\@");
3240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
324162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($PName);
3242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cover_stdcxx_typedef($)
3246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
3248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)}
3249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # take the shortest typedef
3251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: there may be more than
3252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # one typedefs to the same type
3253ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Covers[0];
3254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3255f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Covered = $TypeName;
3256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName=~s/(>)[ ]*(const|volatile|restrict| |\*|\&)\Z/$1/g){};
3257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my @Covers = sort {length($a)<=>length($b)} sort keys(%{$StdCxxTypedef{$Version}{$TypeName}}))
3258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3259f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $Cover = $Covers[0])
3260f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
3261f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\W|\Z)/$Cover$1/g;
3262f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Covered=~s/\b\Q$TypeName\E(\w|\Z)/$Cover $1/g;
3263f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
32659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return formatName($Covered, "T");
3266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeIntCst($)
3269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $CstId = $_[0];
327162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CstTypeId = getTreeAttr_Type($CstId);
3272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($EnumMembName_Id{$Version}{$CstId}) {
3273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $EnumMembName_Id{$Version}{$CstId};
3274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif((my $Value = getTreeValue($CstId)) ne "")
3276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3277dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Value eq "0")
3278dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
327962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "false";
3281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "0";
3284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3286dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Value eq "1")
3287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
328862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$CstTypeId} eq "boolean_type") {
3289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "true";
3290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "1";
3293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Value;
3297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNodeStrCst($)
3303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3304dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3305dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3306dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/strg[ ]*: (.+) lngt:[ ]*(\d+)/)
330701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
330801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($LibInfo{$Version}{"info_type"}{$_[0]} eq "string_cst")
330901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # string length is N-1 because of the null terminator
331001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2-1);
331101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
331201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            else
331301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # identifier_node
331401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return substr($1, 0, $2);
331501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
3316dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
332162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getMemPtrAttr($$$)
3322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # function, method and field pointers
332362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($PtrId, $TypeId, $Type) = @_;
3324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo = $LibInfo{$Version}{"info"}{$PtrId};
3325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr") {
3326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemInfo = $LibInfo{$Version}{"info"}{$TypeId};
3327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemInfo_Type = $LibInfo{$Version}{"info_type"}{$PtrId};
3329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemPtrName = "";
333062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TypeAttr = ("Size"=>$WORD_SIZE{$Version}, "Type"=>$Type, "Tid"=>$TypeId);
3331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "MethodPtr")
3332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # size of "method pointer" may be greater than WORD size
333301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Size = getSize($TypeId))
333401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
333501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $Size/=$BYTE_SIZE;
333601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr{"Size"} = "$Size";
333762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3339f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
3340f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
3341f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Return
3343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FieldPtr")
3344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
334562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %ReturnAttr = getTypeAttr($PtrId);
3346989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($ReturnAttr{"Name"}) {
3347989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3348989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
3349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Return"} = $PtrId;
3350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
3352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/retn[ ]*:[ ]*\@(\d+) /)
3354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnTypeId = $1;
335662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %ReturnAttr = getTypeAttr($ReturnTypeId);
335762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $ReturnAttr{"Name"})
335862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
335962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return ();
3360989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
336162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $MemPtrName .= $ReturnAttr{"Name"};
3362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeAttr{"Return"} = $ReturnTypeId;
3363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Class
3366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemInfo=~/(clas|cls)[ ]*:[ ]*@(\d+) /)
3367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Class"} = $2;
336962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class = getTypeAttr($TypeAttr{"Class"});
3370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Class{"Name"}) {
3371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (".$Class{"Name"}."\:\:*)";
3372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
3374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MemPtrName .= " (*)";
3375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
3378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (*)";
3379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Parameters
3381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type eq "FuncPtr"
3382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type eq "MethodPtr")
3383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ParamTypeName = ();
3385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemInfo=~/prms[ ]*:[ ]*@(\d+) /)
3386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3387989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $PTypeInfoId = $1;
338801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my ($Pos, $PPos) = (0, 0);
3389989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            while($PTypeInfoId)
3390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
3391989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                my $PTypeInfo = $LibInfo{$Version}{"info"}{$PTypeInfoId};
3392989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($PTypeInfo=~/valu[ ]*:[ ]*@(\d+) /)
3393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
339462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $PTypeId = $1;
339562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %ParamAttr = getTypeAttr($PTypeId);
3396989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if(not $ParamAttr{"Name"})
3397989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    { # templates (template_type_parm), etc.
3398989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        return ();
3399989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3400989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    if($ParamAttr{"Name"} eq "void") {
3401989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3402989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
340362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Pos!=0 or $Type ne "MethodPtr")
3404989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
340501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TypeAttr{"Param"}{$PPos++}{"type"} = $PTypeId;
3406989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        push(@ParamTypeName, $ParamAttr{"Name"});
3407989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
340862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($PTypeInfoId = getNextElem($PTypeInfoId)) {
340962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Pos+=1;
3410989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3411989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    else {
3412989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                        last;
3413989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
3414989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
3415989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
3416989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    last;
3417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
3418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MemPtrName .= " (".join(", ", @ParamTypeName).")";
3421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($MemPtrName, "T");
3423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
3424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeTypeName($)
3427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
34280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
34290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
34310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "integer_type")
3432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
34330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Name = getNameByInfo($TypeId))
34340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # bit_size_type
34350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Name;
34360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
34370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($Info=~/unsigned/) {
3438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "unsigned int";
3439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
3441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "int";
3442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
34444b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        elsif($Info=~/name[ ]*:[ ]*@(\d+) /) {
34450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return getNameByInfo($1);
34460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3448dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
3449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
34510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFuncPtr($)
3452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
34530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
34540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
34550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
34560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/unql[ ]*:/ and $Info!~/qual[ ]*:/) {
34580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 0;
34590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $InfoT1 = $LibInfo{$Version}{"info_type"}{$_[0]}
34620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    and my $InfoT2 = $LibInfo{$Version}{"info_type"}{$Ptd})
3463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
34640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($InfoT1 eq "pointer_type"
34650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $InfoT2 eq "function_type") {
34660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
34680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
34700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isMethodPtr($)
34730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Ptd = pointTo($_[0]);
34750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0 if(not $Ptd);
34760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
34770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
34780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "record_type"
34790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$Ptd} eq "method_type"
34800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
34810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
34840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
34850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub isFieldPtr($)
34880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
34890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
34910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "offset_type"
34920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $Info=~/ ptrmem /) {
34930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return 1;
3494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
34950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
34960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
34970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
34980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
34990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub pointTo($)
35000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
35010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
35020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
35030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+)/) {
35040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $1;
3505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "";
35080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
35090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
35100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getTypeTypeByTypeId($)
35110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
35120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeId = $_[0];
35130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $TType = $LibInfo{$Version}{"info_type"}{$TypeId})
35140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
35150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $NType = $NodeType{$TType};
35160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($NType eq "Intrinsic") {
35170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
35180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFuncPtr($TypeId)) {
35200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FuncPtr";
35210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isMethodPtr($TypeId)) {
35230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "MethodPtr";
35240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(isFieldPtr($TypeId)) {
35260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "FieldPtr";
35270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
35280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($NType ne "Other") {
35290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return $NType;
35300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
35320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Unknown";
3533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
353574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkomy %UnQual = (
353674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "r"=>"restrict",
353774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "v"=>"volatile",
353874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "c"=>"const",
353974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "cv"=>"const volatile"
354074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko);
354174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
3542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getQual($)
3543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
3545dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$TypeId})
3546dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3547dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($Qual, $To) = ();
3548dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/qual[ ]*:[ ]*(r|c|v|cv) /) {
3549dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Qual = $UnQual{$1};
3550dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3551dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*\@(\d+)/) {
3552dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $To = $1;
3553dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3554dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Qual and $To) {
3555dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return ($Qual, $To);
3556dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ();
3559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
35610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualType($)
35620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
35630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($_[0] eq "const volatile") {
35640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "ConstVolatile";
35650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ucfirst($_[0]);
35670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
35680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
356962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTypeType($)
35700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
357162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
357262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeDeclId = getTypeDeclId($TypeId);
357362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
35740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # support for old GCC versions
357562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq $TypeDeclId) {
357662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "Typedef";
357762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
35780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
35800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
35819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(($Qual or $To) and $TypeDeclId
35829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and (getTypeId($TypeDeclId) ne $TypeId))
35830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
358462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return getQualType($Qual);
35850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
358662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MissedBase_R{$Version}{$TypeId}
358762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and isTypedef($TypeId)) {
35880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Typedef";
35890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual)
35910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
35920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return getQualType($Qual);
35930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
35949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
35959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info=~/unql[ ]*:[ ]*\@(\d+)/)
35969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # typedef struct { ... } name
35979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TypeTypedef{$Version}{$TypeId} = $1;
35989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
35999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
36000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $TypeType = getTypeTypeByTypeId($TypeId);
36010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($TypeType eq "Struct")
36020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
36030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($TypeDeclId
36040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $LibInfo{$Version}{"info_type"}{$TypeDeclId} eq "template_decl") {
36050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return "Template";
36060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
36070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
36080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $TypeType;
36090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
36100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
361162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub isTypedef($)
361262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
3613177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0])
361462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_[0]} eq "vector_type")
3616177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # typedef float La_x86_64_xmm __attribute__ ((__vector_size__ (16)));
3617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return 0;
3618177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3619177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
3620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3621e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if(my $TDid = getTypeDeclId($_[0]))
3622e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            {
3623e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(getTypeId($TDid) eq $_[0]
3624e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                and getNameByInfo($TDid))
3625e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                {
3626e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if($Info=~/unql[ ]*:[ ]*\@(\d+) /) {
3627e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                        return $1;
3628e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
3629e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
3630177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
363162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
363262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
363362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
363462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
363562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
363662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectBaseType($)
3637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
363862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
363962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $MissedTypedef{$Version}{$TypeId})
364062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add missed typedefs
364162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MissedTypedef{$Version}{$TypeId}{"TDid"} eq getTypeDeclId($TypeId)) {
364262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($TypeId, "");
364362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
36460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $InfoType = $LibInfo{$Version}{"info_type"}{$TypeId};
364762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
364862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB_R = $MissedBase_R{$Version}{$TypeId};
364962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MB = $MissedBase{$Version}{$TypeId};
365062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
3651dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($Qual, $To) = getQual($TypeId);
36520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(($Qual or $To) and $Info=~/name[ ]*:[ ]*\@(\d+) /
365362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (getTypeId($1) ne $TypeId)
365462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and (not $MB_R or getTypeId($1) ne $MB_R))
36550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types (special)
365662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return (getTypeId($1), $Qual);
365762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
365862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($MB)
365962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # add base
366062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($MB, "");
3661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
366262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(not $MB_R and my $Bid = isTypedef($TypeId))
3663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # typedefs
366462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($Bid, "");
3665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($Qual or $To)
36670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # qualified types
366862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return ($To, $Qual);
3669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "reference_type")
3671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
36720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/refd[ ]*:[ ]*@(\d+) /) {
367362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "&");
3674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "array_type")
3677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
36780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/elts[ ]*:[ ]*@(\d+) /) {
367962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "");
3680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
36820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($InfoType eq "pointer_type")
3683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
36840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/ptd[ ]*:[ ]*@(\d+) /) {
368562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($1, "*");
3686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3688177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3689177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return (0, "");
3690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo_All()
3693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "function_decl") {
369762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getSymbolInfo($_);
3698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3700177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3701177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($ADD_TMPL_INSTANCES)
3702177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
3703177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # templates
3704177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Sid (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$Version}}))
3705177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
3706177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Map = ();
3707177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3708177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $ClassId = $SymbolInfo{$Version}{$Sid}{"Class"})
3709177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3710177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TemplateMap{$Version}{$ClassId})
3711177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3712177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%{$TemplateMap{$Version}{$ClassId}})) {
3713177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Map{$_} = $TemplateMap{$Version}{$ClassId}{$_};
3714177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
3715177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3716177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3717177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3718177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TemplateMap{$Version}{$Sid})
3719177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3720177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$TemplateMap{$Version}{$Sid}})) {
3721177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Map{$_} = $TemplateMap{$Version}{$Sid}{$_};
3722177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3723177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3724177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3725177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $SymbolInfo{$Version}{$Sid}{"Param"})
3726177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
3727177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (keys(%{$SymbolInfo{$Version}{$Sid}{"Param"}}))
3728177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
3729177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $PTid = $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"};
3730177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $SymbolInfo{$Version}{$Sid}{"Param"}{$_}{"type"} = instType(\%Map, $PTid, $Version);
3731177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
3732177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3733177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Return = $SymbolInfo{$Version}{$Sid}{"Return"}) {
3734177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $SymbolInfo{$Version}{$Sid}{"Return"} = instType(\%Map, $Return, $Version);
3735177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
3736177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
3737177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
3738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo_All()
3741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort {int($b)<=>int($a)} keys(%{$LibInfo{$Version}{"info"}}))
3743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order
3744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info_type"}{$_} eq "var_decl") {
374562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            getVarInfo($_);
3746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isBuiltIn($) {
3751dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return ($_[0] and $_[0]=~/\<built\-in\>|\<internal\>|\A\./);
3752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVarInfo($)
3755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
375701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $NSid = getTreeAttr_Scpe($InfoId))
3758dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
3759dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $NSInfoType = $LibInfo{$Version}{"info_type"}{$NSid};
3760dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($NSInfoType and $NSInfoType eq "function_decl") {
3761dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return;
3762dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
3765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
3766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"})) {
3767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
377062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = getTreeStr(getTreeAttr_Name($InfoId));
3771850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $ShortName) {
3772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3775850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($ShortName=~/\Atmp_add_class_\d+\Z/) {
3776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
3778850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3779850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = $ShortName;
3780f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
3781f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
3782f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
3783f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
3784f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
3785f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
3786f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
3787f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
3788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
37899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
3790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate mangled name
3791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
3792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
3793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
37940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
37959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($ShortName, "_Z")==0)
37960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # _ZTS, etc.
3797850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
37980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
37990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(isPrivateData($SymbolInfo{$Version}{$InfoId}{"MnglName"}))
38000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
38010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
38020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
38030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
3804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Data"} = 1;
380562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = getTypeId($InfoId))
38060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
3807177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Rid}
3808177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Rid}{"Name"})
3809177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
38100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
38110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            return;
38120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
381362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Rid;
381462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Val = getDataVal($InfoId, $Rid);
38150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Val) {
38160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Value"} = $Val;
38170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
3818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    set_Class_And_Namespace($InfoId);
382062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
382162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
3822177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
3823177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
3824177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
382562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
382662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
382762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
382862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
382935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
383035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
3831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
383235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3834dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
3835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
3836850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
38385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $CheckHeadersOnly)
38395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
38405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"Class"})
38415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        {
38425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}
38435c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
38445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
38455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if(link_symbol($ShortName, $Version, "-Deps"))
38465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                { # "const" global data is mangled as _ZL... in the TU dump
38475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                  # but not mangled when compiling a C shared library
38485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
38495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
38505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
38515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
38525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
3853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
3854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for some symbols (_ZTI) the short name is the mangled name
38579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($ShortName, "_Z")==0) {
3858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
3863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"MnglName"} = linkSymbol($InfoId);
3864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
3866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
3867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
3868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # link MS C++ symbols from library with GCC symbols from headers
3869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
3870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
3871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"}) {
3874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $ShortName;
3875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3876850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
3877850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
3878850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
3879850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
3880850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
3881850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return;
3882850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
3883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
388462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
388562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
388662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
388762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
388862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
388962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
389062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
389162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
3892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setFuncAccess($InfoId);
38949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_ZTV")==0) {
3895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
3896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShortName=~/\A(_Z|\?)/) {
3898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"ShortName"});
3899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
390074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
390174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
390274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
390374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
3904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
3906850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub isConstType($$)
3907850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
3908850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
390962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Base = get_Type($TypeId, $LibVersion);
3910850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    while(defined $Base{"Type"} and $Base{"Type"} eq "Typedef") {
3911f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        %Base = get_OneStep_BaseType($Base{"Tid"}, $TypeInfo{$LibVersion});
3912850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
3913850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Base{"Type"} eq "Const");
3914850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
3915850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTrivialName($$)
3917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
3918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeInfoId, $TypeId) = @_;
3919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeAttr = ();
3920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"} = getNameByInfo($TypeInfoId);
3921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
3922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = getTreeTypeName($TypeId);
3923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3924dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
392562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
3926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Name"}=~s/<(.+)\Z//g; # GCC 3.4.4 add template params to the name
39271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
39281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
39291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $NameSpaceId = $TypeId;
393001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        while(my $NSId = getTreeAttr_Scpe(getTypeDeclId($NameSpaceId)))
39311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # searching for a first not anon scope
39321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NSId eq $NameSpaceId) {
39331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                last;
39341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
39351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
39361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
39371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace(getTypeDeclId($TypeId));
39381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $TypeAttr{"NameSpace"}
39392956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko                or not isAnon($TypeAttr{"NameSpace"})) {
39401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    last;
39411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
39421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3943177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $NameSpaceId = $NSId;
39441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
39451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
39461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
39471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
394801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $NameSpaceId = getTreeAttr_Scpe($TypeInfoId))
39491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
39501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($NameSpaceId ne $TypeId) {
39511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TypeAttr{"NameSpace"} = getNameSpace($TypeInfoId);
39521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
3953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
3954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39552956b9768547150679a9fde09a13d85bb4f8c972Andrey Ponomarenko    if($TypeAttr{"NameSpace"} and not isAnon($TypeAttr{"Name"})) {
3956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}, "T");
3959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isAnon($TypeAttr{"Name"}))
39601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # anon-struct-header.h-line
3961dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $TypeAttr{"Name"} = "anon-".lc($TypeAttr{"Type"})."-";
3962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Name"} .= $TypeAttr{"Header"}."-".$TypeAttr{"Line"};
3963dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($TypeAttr{"NameSpace"}) {
3964dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $TypeAttr{"Name"} = $TypeAttr{"NameSpace"}."::".$TypeAttr{"Name"};
3965dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
3966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3967b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId}
3968b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko    and getTypeDeclId($TypeId) eq $TypeInfoId)
3969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3970b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type")) {
3971b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."< ".join(", ", @TParams)." >", "T");
3972b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3973b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
3974b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $TypeAttr{"Name"} = formatName($TypeAttr{"Name"}."<...>", "T");
3975b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
3976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
3977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"});
3978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
3979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
398062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTrivialTypeAttr($)
3981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
398262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeId = $_[0];
398362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $TypeInfoId = getTypeDeclId($_[0]);
3984850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %TypeAttr = ();
3986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
3987850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TemplateDecl{$Version}{$TypeId})
3988850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # template_decl
3989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $TypeAttr{"Template"} = 1;
399062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
3991850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
3992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setTypeAccess($TypeId, \%TypeAttr);
3993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Header"}, $TypeAttr{"Line"}) = getLocation($TypeInfoId);
3994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isBuiltIn($TypeAttr{"Header"}))
3995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
3996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Header"});
3997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"Line"});
3998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
39992489ef88760861175102e4508089608391beead3Andrey Ponomarenko
400062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeAttr{"Type"} = getTypeType($TypeId);
4001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($TypeAttr{"Name"}, $TypeAttr{"NameSpace"}) = getTrivialName($TypeInfoId, $TypeId);
4002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"Name"}) {
4003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
4004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypeAttr{"NameSpace"}) {
4006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        delete($TypeAttr{"NameSpace"});
4007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
40092489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Intrinsic")
40102489ef88760861175102e4508089608391beead3Andrey Ponomarenko    {
40112489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(defined $TypeAttr{"Header"})
40122489ef88760861175102e4508089608391beead3Andrey Ponomarenko        {
40132489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if($TypeAttr{"Header"}=~/\Adump[1-2]\.[ih]\Z/)
40142489ef88760861175102e4508089608391beead3Andrey Ponomarenko            { # support for SUSE 11.2
40152489ef88760861175102e4508089608391beead3Andrey Ponomarenko              # integer_type has srcp dump{1-2}.i
40162489ef88760861175102e4508089608391beead3Andrey Ponomarenko                delete($TypeAttr{"Header"});
40172489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
40182489ef88760861175102e4508089608391beead3Andrey Ponomarenko        }
40192489ef88760861175102e4508089608391beead3Andrey Ponomarenko    }
40202489ef88760861175102e4508089608391beead3Andrey Ponomarenko
4021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Tmpl = undef;
4022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
402362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Type"}{$TypeId})
40241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
4025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $Tmpl = $BasicTemplate{$Version}{$TypeId};
4026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
402762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my @TParams = getTParams($TypeId, "Type"))
40281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
4029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (0 .. $#TParams)
4030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Val = $TParams[$Pos];
4032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"TParam"}{$Pos}{"name"} = $Val;
4033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not defined $TypeAttr{"Template"})
4035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my %Base = get_BaseType($TemplateInstance{$Version}{"Type"}{$TypeId}{$Pos}, $Version);
4037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Base{"Type"} eq "TemplateParam"
4039177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or defined $Base{"Template"}) {
4040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeAttr{"Template"} = 1;
4041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Tmpl)
4045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
4047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = $Val;
4049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if($Val eq $Arg) {
4051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $TypeAttr{"Template"} = 1;
4052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
4053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4056177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
4058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4059177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
4060177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4061177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($Pos>$#TParams)
4062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4063177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
4064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TemplateMap{$Version}{$TypeId}{$Arg} = "";
4065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4066177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ADD_TMPL_INSTANCES)
4071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4072e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            if($Tmpl)
4073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4074e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(my $MainInst = getTreeAttr_Type($Tmpl))
4075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4076e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Flds($TypeId))
4077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4078177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Flds = getTreeAttr_Flds($MainInst)) {
4079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " flds: \@$Flds ";
4080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
4081e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    }
4082e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    if(not getTreeAttr_Binf($TypeId))
4083e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    {
4084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        if(my $Binf = getTreeAttr_Binf($MainInst)) {
4085177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            $LibInfo{$Version}{"info"}{$TypeId} .= " binf: \@$Binf ";
4086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        }
4087177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4088177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
40891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
40901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
40911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4092177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4093177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $StaticFields = setTypeMemb($TypeId, \%TypeAttr);
4094177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
409501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Size = getSize($TypeId))
409601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
409701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Size = $Size/$BYTE_SIZE;
409801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeAttr{"Size"} = "$Size";
4099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
41009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
4101177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
4102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($ExtraDump)
4103177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4104177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not defined $TypeAttr{"Memb"}
4105177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not $Tmpl)
4106177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # declaration only
4107177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"Forward"} = 1;
4108177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4109177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
41109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
411174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
4112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
411374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    and ($StaticFields or detect_lang($TypeId)))
4114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr{"Type"} = "Class";
4116850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $TypeAttr{"Copied"} = 1; # default, will be changed in getSymbolInfo()
4117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Struct"
4119850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    or $TypeAttr{"Type"} eq "Class")
4120850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
412162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Skip = setBaseClasses($TypeId, \%TypeAttr);
4122850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Skip) {
4123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return ();
4124850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
4125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4126f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $Algn = getAlgn($TypeId)) {
4127f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $TypeAttr{"Algn"} = $Algn/$BYTE_SIZE;
4128f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
4129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    setSpec($TypeId, \%TypeAttr);
413074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
413174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeAttr{"Type"}=~/\A(Struct|Union|Enum)\Z/)
413274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
413374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $TypedefToAnon{$TypeId}
4134177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        and not defined $TemplateInstance{$Version}{"Type"}{$TypeId})
413574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
413674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not isAnon($TypeAttr{"Name"})) {
413774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeAttr{"Name"} = lc($TypeAttr{"Type"})." ".$TypeAttr{"Name"};
413874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
413974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
414074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
414174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
4142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $TypeAttr{"Tid"} = $TypeId;
4143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VTable = $ClassVTable_Content{$Version}{$TypeAttr{"Name"}})
4144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Entries = split(/\n/, $VTable);
4146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $#Entries)
4147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Entry = $Entries[$_];
4149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry=~/\A(\d+)\s+(.+)\Z/) {
4150177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeAttr{"VTable"}{$1} = simplifyVTable($2);
4151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
415482bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
415582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if($TypeAttr{"Type"} eq "Enum")
415682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    {
415782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if(not $TypeAttr{"NameSpace"})
415882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
415982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            foreach my $Pos (keys(%{$TypeAttr{"Memb"}}))
416082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            {
416182bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                my $MName = $TypeAttr{"Memb"}{$Pos}{"name"};
41628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $MVal = $TypeAttr{"Memb"}{$Pos}{"value"};
416382bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                $EnumConstants{$Version}{$MName} = {
41648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    "Value"=>$MVal,
416582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                    "Header"=>$TypeAttr{"Header"}
416682bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko                };
41678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(isAnon($TypeAttr{"Name"}))
41688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
4169177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if($ExtraDump
4170177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or is_target_header($TypeAttr{"Header"}, $Version))
4171177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
4172177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$Constants{$Version}{$MName}} = (
4173177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Value" => $MVal,
4174177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                            "Header" => $TypeAttr{"Header"}
4175177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        );
4176177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
41778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
417882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko            }
417982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        }
418082bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    }
418174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
41824b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    {
41834b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(defined $TypedefToAnon{$TypeId}) {
41844b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr{"AnonTypedef"} = 1;
41854b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        }
41864b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
418782bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko
4188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %TypeAttr;
4189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4191177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub simplifyVTable($)
4192177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
4193177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $Content = $_[0];
4194177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Content=~s/ \[with (.+)]//)
4195177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # std::basic_streambuf<_CharT, _Traits>::imbue [with _CharT = char, _Traits = std::char_traits<char>]
4196177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my @Elems = separate_Params($1, 0, 0))
4197177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
4198177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Elem (@Elems)
4199177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
4200177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Elem=~/\A(.+?)\s*=\s*(.+?)\Z/)
4201177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
4202177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my ($Arg, $Val) = ($1, $2);
4203177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4204177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $DEFAULT_STD_ARGS{$Arg}) {
4205177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/,\s*$Arg\b//g;
4206177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4207177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    else {
4208177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Content=~s/\b$Arg\b/$Val/g;
4209177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
4210177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
4211177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
4212177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
4213177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
4214177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4215177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Content;
4216177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
4217177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
4218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lang($)
4219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId = $_[0];
4221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
422262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(check_gcc($GCC_PATH, "4"))
42231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4 fncs-node points to only non-artificial methods
4224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Info=~/(fncs)[ ]*:[ ]*@(\d+) /);
4225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
42271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
422862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Fncs = getTreeAttr_Fncs($TypeId);
4229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Fncs)
4230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
423162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($LibInfo{$Version}{"info"}{$Fncs}!~/artificial/) {
4232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
4233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
423462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Fncs = getTreeAttr_Chan($Fncs);
4235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
4238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setSpec($$)
4241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Info=~/\s+spec\s+/) {
4245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Spec"} = 1;
4246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
424962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub setBaseClasses($$)
4250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
425162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
4252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$TypeId};
4253177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Binf = getTreeAttr_Binf($TypeId))
4254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4255177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Info = $LibInfo{$Version}{"info"}{$Binf};
4256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
4257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Info=~s/(pub|public|prot|protected|priv|private|)[ ]+binf[ ]*:[ ]*@(\d+) //)
4258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Access, $BInfoId) = ($1, $2);
4260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ClassId = getBinfClassId($BInfoId);
4261b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4262b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            if($ClassId==$TypeId)
4263b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            { # class A<N>:public A<N-1>
4264b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko                next;
4265b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            }
4266b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko
4267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $CType = $LibInfo{$Version}{"info_type"}{$ClassId};
4268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CType or $CType eq "template_type_parm"
4269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $CType eq "typename_type")
4270850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # skip
4271177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                # return 1;
4272850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
4273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseInfo = $LibInfo{$Version}{"info"}{$BInfoId};
42744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($Access=~/prot/) {
4275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "protected";
4276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
42774b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            elsif($Access=~/priv/) {
4278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"access"} = "private";
4279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
428001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeAttr->{"Base"}{$ClassId}{"pos"} = "$Pos";
4281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseInfo=~/virt/)
42821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual base
4283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TypeAttr->{"Base"}{$ClassId}{"virtual"} = 1;
4284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Class_SubClasses{$Version}{$ClassId}{$TypeId}=1;
42864b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $Pos += 1;
4287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4289850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
4290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getBinfClassId($)
4293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $LibInfo{$Version}{"info"}{$_[0]};
4295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Info=~/type[ ]*:[ ]*@(\d+) /;
4296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $1;
4297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangledFormat($$)
4300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion) = @_;
4302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name = uncover_typedefs($Name, $LibVersion);
4303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Name=~s/([^\w>*])(const|volatile)(,|>|\Z)/$1$3/g){};
4304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\(\w+\)(\d)/$1/;
4305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
4306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub modelUnmangled($$)
4309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $Compiler) = @_;
4311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId}) {
4312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId};
4313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $PureSignature = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
4315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = "~".$PureSignature;
4317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Data"})
4319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@Params, @ParamTypes) = ();
4321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$Version}{$InfoId}{"Param"}
4322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
4323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$Version}{$InfoId}{"Param"}});
4324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"type"};
4328f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $PName = $SymbolInfo{$Version}{$InfoId}{"Param"}{$ParamPos}{"name"};
4329f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PType = get_PureType($PId, $TypeInfo{$Version});
4330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PTName = unmangledFormat($PType{"Name"}, $Version);
4331f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
4332f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($PName eq "this"
4333f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method")
4334f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
4335f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
4336f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
4337f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
433862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $PTName=~s/\b(restrict|register)\b//g;
4339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC") {
434062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $PTName=~s/\blong long\b/__int64/;
4341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @ParamTypes = (@ParamTypes, $PTName);
4343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@ParamTypes) {
4345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature .= "(".join(", ", @ParamTypes).")";
4346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Compiler eq "MSVC")
4350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
4351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "(void)";
4352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # GCC
4355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PureSignature .= "()";
4356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = delete_keywords($PureSignature);
4359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
4361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
436262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ClassName = unmangledFormat($TypeInfo{$Version}{$ClassId}{"Name"}, $Version);
4363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $ClassName."::".$PureSignature;
4364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $NS = $SymbolInfo{$Version}{$InfoId}{"NameSpace"}) {
4366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature = $NS."::".$PureSignature;
4367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Const"}) {
4369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " const";
4370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Volatile"}) {
4372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $PureSignature .= " volatile";
4373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShowReturn = 0;
4375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "MSVC"
4376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Data"})
4377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
438062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(defined $TemplateInstance{$Version}{"Func"}{$InfoId}
438162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and keys(%{$TemplateInstance{$Version}{"Func"}{$InfoId}}))
4382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ShowReturn=1;
4384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowReturn)
4386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled names for template function specializations include return value
4387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ReturnId = $SymbolInfo{$Version}{$InfoId}{"Return"})
4388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4389f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %RType = get_PureType($ReturnId, $TypeInfo{$Version});
4390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ReturnName = unmangledFormat($RType{"Name"}, $Version);
4391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $PureSignature = $ReturnName." ".$PureSignature;
4392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
43949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"modelUnmangled"}{$Version}{$Compiler}{$InfoId} = formatName($PureSignature, "S"));
4395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_symbol($$$)
4398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # mangling for simple methods
4399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # see gcc-4.6.0/gcc/cp/mangle.c
4400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Compiler) = @_;
4401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler}) {
4402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler};
4403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = "";
4405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Compiler eq "GCC") {
44061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_GCC($InfoId, $LibVersion);
4407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Compiler eq "MSVC") {
44091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Mangled = mangle_symbol_MSVC($InfoId, $LibVersion);
4410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"mangle_symbol"}{$LibVersion}{$InfoId}{$Compiler} = $Mangled);
4412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_MSVC($$)
4415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
4418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
44201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub mangle_symbol_GCC($$)
4421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # see gcc-4.6.0/gcc/cp/mangle.c
4422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion) = @_;
4423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $ClassId, $NameSpace) = ("_Z", 0, "");
44241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
4425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Repl = ();# SN_ replacements
4426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
4427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledClass = mangle_param($ClassId, $LibVersion, \%Repl);
4429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledClass!~/\AN/) {
4430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass = "N".$MangledClass;
4431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/E\Z//;
4434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Volatile"}) {
4436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NV/;
4437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Const"}) {
4439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledClass=~s/\AN/NK/;
4440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledClass;
4442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($NameSpace = $SymbolInfo{$LibVersion}{$InfoId}{"NameSpace"})
4444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # mangled by name due to the absence of structured info
4445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = mangle_ns($NameSpace, $LibVersion, \%Repl);
4446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNS!~/\AN/) {
4447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS = "N".$MangledNS;
4448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS=~s/E\Z//;
4451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $MangledNS;
4453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
445407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($SymbolInfo{$LibVersion}{$InfoId}{"ShortName"});
44551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my @TParams = ();
445635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if(my @TPos = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}}))
44571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # parsing mode
445835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        foreach (@TPos) {
445935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            push(@TParams, $SymbolInfo{$LibVersion}{$InfoId}{"TParam"}{$_}{"name"});
446035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
44611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
44621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    elsif($TmplParams)
44631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # remangling mode
44641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko      # support for old ABI dumps
446507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @TParams = separate_Params($TmplParams, 0, 0);
4466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"}) {
4468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "C1";
4469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "D0";
4472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($ShortName)
4474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
44751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
44761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
44771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
4478850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and isConstType($Return, $LibVersion))
44791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # "const" global data is mangled as _ZL...
44801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Mangled .= "L";
44811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
44821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
4483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShortName=~/\Aoperator(\W.*)\Z/)
4484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Op = $1;
4486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Op=~s/\A[ ]+//g;
4487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $OpMngl = $OperatorMangling{$Op}) {
4488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= $OpMngl;
4489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else { # conversion operator
4491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= "cv".mangle_param(getTypeIdByName($Op, $LibVersion), $LibVersion, \%Repl);
4492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= length($ShortName).$ShortName;
4496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
45001477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko            foreach my $TParam (@TParams) {
4501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, \%Repl);
4502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ClassId and @TParams) {
4506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($ShortName, \%Repl, 0);
4507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ClassId or $NameSpace) {
4510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4512850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(@TParams)
4513850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
45141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Return) {
4515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($Return, $LibVersion, \%Repl);
4516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
4519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = ();
4521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
4522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Destructor"}) {
4523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @Params = keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
4524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a) <=> int($b)} @Params)
4526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # checking parameters
4527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamType_Id = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$ParamPos}{"type"};
4528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($ParamType_Id, $LibVersion, \%Repl);
4529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = correct_incharge($InfoId, $LibVersion, $Mangled);
4535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = write_stdcxx_substitution($Mangled);
4536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mangled eq "_Z") {
4537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub correct_incharge($$$)
4543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($InfoId, $LibVersion, $Mangled) = @_;
4545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$LibVersion}{$InfoId}{"Constructor"})
4546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4548f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/C1([EI])/C2$1/;
4549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
4552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4554f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D0([EI])/D1$1/;
4555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MangledNames{$LibVersion}{$Mangled}) {
4557f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Mangled=~s/D1([EI])/D2$1/;
4558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
456307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub template_Base($)
4564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # NOTE: std::_Vector_base<mysqlpp::mysql_type_info>::_Vector_impl
45651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko  # NOTE: operators: >>, <<
4566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
45671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Name!~/>\Z/ or $Name!~/</) {
4568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Name;
4569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TParams = $Name;
45711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($TParams, "<"))
45721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # search for the last <T>
4573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TParams = substr($TParams, $CPos);
4574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
45751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($TParams=~s/\A<(.+)>\Z/$1/) {
45761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Name=~s/<\Q$TParams\E>\Z//;
45771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
45781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    else
45791693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # error
45801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TParams = "";
45811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
4582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $TParams);
4583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_ns($)
4586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
4588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @NS = ();
45891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    while(my $CPos = find_center($Name, ":"))
4590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@NS, substr($Name, 0, $CPos));
4592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name = substr($Name, $CPos);
4593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Name=~s/\A:://;
4594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (join("::", @NS), $Name);
4596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_ns($$$)
4599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $LibVersion, $Repl) = @_;
4601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Tid = $TName_Tid{$LibVersion}{$Name})
4602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Mangled = mangle_param($Tid, $LibVersion, $Repl);
4604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled=~s/\AN(.+)E\Z/$1/;
4605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Mangled;
4606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($MangledNS, $SubNS) = ("", "");
4611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($SubNS, $Name) = get_sub_ns($Name);
4612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($Name).$Name;
4616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        add_substitution($MangledNS, $Repl, 0);
4617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $MangledNS;
4618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_param($$$)
4622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($PTid, $LibVersion, $Repl) = @_;
4624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MPrefix, $Mangled) = ("", "");
4625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %ReplCopy = %{$Repl};
462662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType = get_BaseType($PTid, $LibVersion);
4627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $BaseType_Name = $BaseType{"Name"};
462874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $BaseType_Name=~s/\A(struct|union|enum) //g;
4629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $BaseType_Name) {
4630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
4631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
463207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($ShortName, $TmplParams) = template_Base($BaseType_Name);
463362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Suffix = get_BaseTypeQual($PTid, $LibVersion);
4634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~s/\s*(const|volatile|restrict)\Z//g){};
4635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Suffix=~/(&|\*|const)\Z/)
4636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*&\Z//) {
4638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "R";
4639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*\*\Z//) {
4641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "P";
4642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*const\Z//)
4644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MPrefix=~/R|P/
4646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $Suffix=~/&|\*/) {
4647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MPrefix .= "K";
4648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Suffix=~s/[ ]*volatile\Z//) {
4651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MPrefix .= "V";
4652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($Suffix=~s/[ ]*restrict\Z//) {
4654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #$MPrefix .= "r";
4655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
4656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Token = $IntrinsicMangling{$BaseType_Name}) {
4658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= $Token;
4659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(Class|Struct|Union|Enum)/)
4661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
46621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my @TParams = ();
466335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if(my @TPos = keys(%{$BaseType{"TParam"}}))
46641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # parsing mode
466535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            foreach (@TPos) {
466635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                push(@TParams, $BaseType{"TParam"}{$_}{"name"});
466735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            }
46681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
46691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        elsif($TmplParams)
46701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # remangling mode
46711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # support for old ABI dumps
467207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            @TParams = separate_Params($TmplParams, 0, 0);
4673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MangledNS = "";
4675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($SubNS, $SName) = get_sub_ns($ShortName);
4676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SubNS) {
4677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MangledNS .= mangle_ns($SubNS, $LibVersion, $Repl);
4678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MangledNS .= length($SName).$SName;
4680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams) {
4681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($MangledNS, $Repl, 0);
4682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "N".$MangledNS;
4684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(@TParams)
4685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # templates
4686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "I";
4687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $TParam (@TParams) {
4688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled .= mangle_template_param($TParam, $LibVersion, $Repl);
4689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "E";
4691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"}=~/(FuncPtr|MethodPtr)/)
4695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($BaseType{"Type"} eq "MethodPtr") {
4697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl)."F";
4698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "PF";
4701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Params = keys(%{$BaseType{"Param"}});
4704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (sort {int($a)<=>int($b)} @Params) {
4705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= mangle_param($BaseType{"Param"}{$Num}{"type"}, $LibVersion, $Repl);
4706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Params) {
4708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled .= "v";
4709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "E";
4711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($BaseType{"Type"} eq "FieldPtr")
4713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= "M".mangle_param($BaseType{"Class"}, $LibVersion, $Repl);
4715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled .= mangle_param($BaseType{"Return"}, $LibVersion, $Repl);
4716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Mangled = $MPrefix.$Mangled;# add prefix (RPK)
4718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Optimized = write_substitution($Mangled, \%ReplCopy))
4719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Mangled eq $Optimized)
4721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ShortName!~/::/)
4723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # remove "N ... E"
4724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MPrefix) {
4725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\A($MPrefix)N(.+)E\Z/$1$2/g;
4726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
4728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Mangled=~s/\AN(.+)E\Z/$1/g;
4729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
4733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mangled = $Optimized;
4734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    add_substitution($Mangled, $Repl, 1);
4737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mangle_template_param($$$)
4741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # types + literals
4742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TParam, $LibVersion, $Repl) = @_;
4743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $TPTid = $TName_Tid{$LibVersion}{$TParam}) {
4744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return mangle_param($TPTid, $LibVersion, $Repl);
4745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A(\d+)(\w+)\Z/)
4747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<1u>::method(...)
4748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$ConstantSuffixR{$2}}.$1."E";
4749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam=~/\A\(([\w ]+)\)(\d+)\Z/)
4751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<(signed char)1>::method(...)
4752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "L".$IntrinsicMangling{$1}.$2."E";
4753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "true")
4755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb1E";
4757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TParam eq "false")
4759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # class_name<true>::method(...)
4760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "Lb0E";
4761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else { # internal error
4763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return length($TParam).$TParam;
4764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub add_substitution($$$)
4768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Value, $Repl, $Rec) = @_;
4770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Rec)
4771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # subtypes
4772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Subs = ($Value);
4773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($Value=~s/\A(R|P|K)//) {
4774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Subs, $Value);
4775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (reverse(@Subs)) {
4777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            add_substitution($_, $Repl, 0);
4778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($Value=~/\AS(\d*)_\Z/);
4782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Value=~s/\AN(.+)E\Z/$1/g;
4783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(defined $Repl->{$Value});
4784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($Value)<=1);
4785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if($StdcxxMangling{$Value});
4786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check for duplicates
4787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Base = $Value;
4788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Replace\E/$Type/;
4793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $OldNum = $Repl->{$Base})
4795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $OldNum;
4797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
4798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Repls = sort {$b<=>$a} values(%{$Repl});
4800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Repls) {
4801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = $Repls[0]+1;
4802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
4804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Value} = -1;
4805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # register duplicates
4807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # upward
4808dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Base = $Value;
4809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (sort {$Repl->{$a}<=>$Repl->{$b}} sort keys(%{$Repl}))
4810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Base eq $Type);
4812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Num = $Repl->{$Type};
4813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Replace = macro_mangle($Num);
4814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Base=~s/\Q$Type\E/$Replace/;
4815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Repl->{$Base} = $Repl->{$Value};
4816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub macro_mangle($)
4820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Num = $_[0];
4822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Num==-1) {
4823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S_";
4824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Code = "";
4828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num<10)
4829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S0_, S1_, S2_, ...
4830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num;
4831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Num>=10 and $Num<=35)
4833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SA_, SB_, SC_, ...
4834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = chr(55+$Num);
4835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
4837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # S10_, S11_, S12_
4838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Code = $Num-26; # 26 is length of english alphabet
4839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "S".$Code."_";
4841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_stdcxx_substitution($)
4845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mangled = $_[0];
4847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdcxxMangling{$Mangled}) {
4848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $StdcxxMangling{$Mangled};
4849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%StdcxxMangling);
4853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = $StdcxxMangling{$MangledType};
4857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #if($Mangled!~/$Replace/) {
4858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            #}
4861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub write_substitution($$)
4867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Mangled, $Repl) = @_;
4869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Repl->{$Mangled}
4870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $MnglNum = $Repl->{$Mangled}) {
4871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Mangled = macro_mangle($MnglNum);
4872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
4874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Repls = keys(%{$Repl});
4876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #@Repls = sort {$Repl->{$a}<=>$Repl->{$b}} @Repls;
4877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # FIXME: how to apply replacements? by num or by pos
4878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Repls = sort {length($b)<=>length($a)} sort {$b cmp $a} @Repls;
4879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MangledType (@Repls)
4880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Replace = macro_mangle($Repl->{$MangledType});
4882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mangled!~/$Replace/) {
4883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/N\Q$MangledType\EE/$Replace/g;
4884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled=~s/\Q$MangledType\E/$Replace/g;
4885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Mangled;
4889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub delete_keywords($)
4892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
489462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $TypeName=~s/\b(enum|struct|union|class) //g;
4895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TypeName;
4896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub uncover_typedefs($$)
4899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
4901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName);
4902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName}) {
4903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"uncover_typedefs"}{$LibVersion}{$TypeName};
4904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
49059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($TypeName_New, $TypeName_Pre) = (formatName($TypeName, "T"), "");
4906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($TypeName_New ne $TypeName_Pre)
4907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
4908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeName_Pre = $TypeName_New;
4909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeName_Copy = $TypeName_New;
4910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Words = ();
491162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        while($TypeName_Copy=~s/\b([a-z_]([\w:]*\w|))\b//io)
4912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
491362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Intrinsic_Keywords{$1}) {
491462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Words{$1} = 1;
491562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
4916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Word (keys(%Words))
4918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
4919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $BaseType_Name = $Typedef_BaseName{$LibVersion}{$Word};
4920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $BaseType_Name);
492162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            next if($TypeName_New=~/\b(struct|union|enum)\s\Q$Word\E\b/);
4922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($BaseType_Name=~/\([\*]+\)/)
4923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # FuncPtr
4924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TypeName_New=~/\Q$Word\E(.*)\Z/)
4925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
4926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Type_Suffix = $1;
4927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TypeName_New = $BaseType_Name;
4928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TypeName_New=~s/\(([\*]+)\)/($1 $Type_Suffix)/) {
49299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $TypeName_New = formatName($TypeName_New, "T");
4930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
4931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
4934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
493562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeName_New=~s/\b\Q$Word\E\b/$BaseType_Name/g) {
49369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $TypeName_New = formatName($TypeName_New, "T");
4937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
4938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
4939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
4940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
4941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"uncover_typedefs"}{$LibVersion}{$TypeName} = $TypeName_New);
4942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
4944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInternal($)
4945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
4946989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
4947989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
4948989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /)
4949989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
4950989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/\*[ ]*INTERNAL[ ]*\*/)
4951989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # _ZN7mysqlpp8DateTimeC1ERKS0_ *INTERNAL*
4952989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return 1;
4953989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
4954989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
4955989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
4956989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
4957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
4958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
49590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getDataVal($$)
49600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
49610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
49620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
49630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
49640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Info=~/init[ ]*:[ ]*@(\d+) /)
49650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
49660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $LibInfo{$Version}{"info_type"}{$1}
49670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $LibInfo{$Version}{"info_type"}{$1} eq "nop_expr")
49688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
49698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $Nop = getTreeAttr_Op($1))
49700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
49718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(defined $LibInfo{$Version}{"info_type"}{$Nop}
49728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $LibInfo{$Version}{"info_type"}{$Nop} eq "addr_expr")
49730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
49748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(my $Addr = getTreeAttr_Op($1)) {
49758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return getInitVal($Addr, $TypeId);
49760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
49770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
49780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
49790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
49800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            else {
49810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getInitVal($1, $TypeId);
49820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
49830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
49840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
49850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
49860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
49870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
49880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getInitVal($$)
49890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
49900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($InfoId, $TypeId) = @_;
49910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
49920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
49930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$InfoId})
49940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
49950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($InfoType eq "integer_cst")
49960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
49970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Val = getNodeIntCst($InfoId);
499862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeId and $TypeInfo{$Version}{$TypeId}{"Name"}=~/\Achar(| const)\Z/)
49990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # characters
50000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Val = chr($Val);
50010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
50020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return $Val;
50030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
50040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($InfoType eq "string_cst") {
50050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return getNodeStrCst($InfoId);
50060d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
500701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($InfoType eq "var_decl")
500801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
500901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Name = getNodeStrCst(getTreeAttr_Mngl($InfoId))) {
501001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    return $Name;
501101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
501201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
50130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
50140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
50150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return undef;
50160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
50170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
5018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub set_Class_And_Namespace($)
5019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
5021989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$InfoId})
5022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5023989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /)
5024dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5025989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $NSInfoId = $1;
5026989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
5027989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
5028989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($InfoType eq "namespace_decl") {
5029989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"NameSpace"} = getNameSpace($InfoId);
5030989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
5031989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($InfoType eq "record_type") {
5032989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Class"} = $NSInfoId;
5033989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
5034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Class"}
5038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"NameSpace"})
5039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5040570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($COMMON_LANGUAGE{$Version} ne "C++")
5041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # skip
5042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
5043570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
5044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
5047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub debugMangling($)
5050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
5052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Mangled = ();
5053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
5054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Mngl = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
5056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Mngl=~/\A(_Z|\?)/) {
5058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Mangled{$Mngl}=$InfoId;
5059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%Mangled), $LibVersion);
5063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Mngl (keys(%Mangled))
5064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5065850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U1 = modelUnmangled($Mangled{$Mngl}, "GCC");
5066850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $U2 = $tr_name{$Mngl};
5067850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($U1 ne $U2) {
5068850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            printMsg("INFO", "INCORRECT MANGLING:\n  $Mngl\n  $U1\n  $U2\n");
5069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub linkSymbol($)
5074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # link symbols from shared libraries
5075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # with the symbols from header files
5076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $InfoId = $_[0];
5077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # try to mangle symbol
507862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if((not check_gcc($GCC_PATH, "4") and $SymbolInfo{$Version}{$InfoId}{"Class"})
5079f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or (check_gcc($GCC_PATH, "4") and not $SymbolInfo{$Version}{$InfoId}{"Class"})
5080f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    or $EMERGENCY_MODE_48)
5081f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # GCC 3.x doesn't mangle class methods names in the TU dump (only functions and global data)
5082f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.x doesn't mangle C++ functions in the TU dump (only class methods) except extern "C" functions
5083f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko      # GCC 4.8 doesn't mangle anything
50841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CheckHeadersOnly)
5085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Mangled = $mangled_name_gcc{modelUnmangled($InfoId, "GCC")}) {
5087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return correct_incharge($InfoId, $Version, $Mangled);
5088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
50901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($CheckHeadersOnly
5091f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or not $BinaryOnly
5092f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        or $EMERGENCY_MODE_48)
50931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # 1. --headers-only mode
50941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # 2. not mangled src-only symbols
50951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Mangled = mangle_symbol($InfoId, $Version, "GCC")) {
50961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return $Mangled;
50971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
50981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setLanguage($$)
5104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Lang) = @_;
5106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $UserLang) {
5107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{$LibVersion} = $Lang;
5108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSymbolInfo($)
5112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
51131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
5114989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isInternal($InfoId)) {
5115989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return;
5116989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
51171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    ($SymbolInfo{$Version}{$InfoId}{"Header"}, $SymbolInfo{$Version}{$InfoId}{"Line"}) = getLocation($InfoId);
51181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Header"}
5119a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    or isBuiltIn($SymbolInfo{$Version}{$InfoId}{"Header"}))
5120a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
51211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncAccess($InfoId);
51251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    setFuncKind($InfoId);
5126a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"PseudoTemplate"})
5127a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
51281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
513174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
51321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"Type"} = getFuncType($InfoId);
5133177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Return = getFuncReturn($InfoId))
513462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5135177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$Return}
5136177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$Return}{"Name"})
5137177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
513862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
513962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
514062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5141177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Return"} = $Return;
514262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
514362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Rid = $SymbolInfo{$Version}{$InfoId}{"Return"})
514462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
514562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$Rid})
514662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
514762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$Rid}{"Tid"}) {
514862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Return"} = $AddedTid;
514962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
515062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
51521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Return"}) {
51531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5155a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Orig = getFuncOrig($InfoId);
5156a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getFuncShortName($Orig);
515774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "\._")!=-1)
515874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
515974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
516074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return;
516174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
516274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
516374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(index($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "tmp_add_func")==0)
5164a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
51651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5168a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko
5169a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(defined $TemplateInstance{$Version}{"Func"}{$Orig})
5170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5171177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $Tmpl = $BasicTemplate{$Version}{$InfoId};
5172177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5173a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my @TParams = getTParams($Orig, "Func");
5174a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(not @TParams)
5175a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
51761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5179177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (0 .. $#TParams)
5180177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5181177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Val = $TParams[$Pos];
5182177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"TParam"}{$Pos}{"name"} = $Val;
5183177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5184177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($Tmpl)
5185177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5186177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos})
5187177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5188177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = $Val;
5189177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5190177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5191177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5192177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5193177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Tmpl)
5194177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5195177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$TemplateArg{$Version}{$Tmpl}}))
5196177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
5197177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($Pos>$#TParams)
5198177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
5199177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    my $Arg = $TemplateArg{$Version}{$Tmpl}{$Pos};
5200177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TemplateMap{$Version}{$InfoId}{$Arg} = "";
5201177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5202177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
52031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5204177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
52051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\Aoperator\W+\Z/)
52061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # operator<< <T>, operator>> <T>
52071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= " ";
52081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
5209b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        if(@TParams) {
5210b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<".join(", ", @TParams).">";
5211b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
5212b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        else {
5213b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} .= "<...>";
5214b6a65eecbd7221a28578e7e01b53d58704421096Andrey Ponomarenko        }
52159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"} = formatName($SymbolInfo{$Version}{$InfoId}{"ShortName"}, "S");
5216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
5218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for GCC 3.4
52191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5221f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(my $MnglName = getTreeStr(getTreeAttr_Mngl($InfoId)))
5222f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
5223f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup eq "windows")
5224f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # cut the offset
5225f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $MnglName=~s/\@\d+\Z//g;
5226f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
5227f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $MnglName;
5228f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
5229f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # NOTE: mangling of some symbols may change depending on GCC version
5230f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.6: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2IT_EERKS_IT_E
5231f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # GCC 4.7: _ZN28QExplicitlySharedDataPointerI11QPixmapDataEC2ERKS1_
5232f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
5233989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
52341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}
52359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")!=0)
5236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
52371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
52401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Destructor"})
5241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # destructors have an empty parameter list
52421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Skip = setFuncParams($InfoId);
524307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Skip)
524407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
52451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5249fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ artificial /i) {
5250fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Artificial"} = 1;
5251fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5252fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
5253fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(set_Class_And_Namespace($InfoId))
5254fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
5255fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5256fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return;
5257fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
5258fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
525962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
526062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
5261177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $TypeInfo{$Version}{$ClassId}
5262177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or not $TypeInfo{$Version}{$ClassId}{"Name"})
5263177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
526462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
526562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return;
526662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
526762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
526835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($LibInfo{$Version}{"info"}{$InfoId}=~/ lang:[ ]*C /i)
526935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    { # extern "C"
52701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Lang"} = "C";
527135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5273dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UserLang and $UserLang eq "C")
5274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C option
52751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
5278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # correct mangled & short names
52791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # C++ or --headers-only mode
52801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"ShortName"}=~/\A__(comp|base|deleting)_(c|d)tor\Z/)
5281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old GCC versions: reconstruct real names for constructors and destructors
52821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"} = getNameByInfo(getTypeDeclId($SymbolInfo{$Version}{$InfoId}{"Class"}));
52831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"ShortName"}=~s/<.+>\Z//;
5284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
52851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # try to mangle symbol (link with libraries)
52871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(my $Mangled = linkSymbol($InfoId)) {
52881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled;
5289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
5292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # link MS C++ symbols from library with GCC symbols from headers
5293dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Mangled1 = $mangled_name{$Version}{modelUnmangled($InfoId, "MSVC")})
5294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # exported symbols
5295dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled1;
5296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5297dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(my $Mangled2 = mangle_symbol($InfoId, $Version, "MSVC"))
5298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual symbols
5299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $Mangled2;
5300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
5304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # not mangled in C
5305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
5306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
53078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $CheckHeadersOnly
53088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function"
53098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and not $SymbolInfo{$Version}{$InfoId}{"Class"})
53108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
53118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Incorrect = 0;
53128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
53138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
53148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
53158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(index($SymbolInfo{$Version}{$InfoId}{"MnglName"}, "_Z")==0
53168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and not link_symbol($SymbolInfo{$Version}{$InfoId}{"MnglName"}, $Version, "-Deps"))
53178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # mangled in the TU dump, but not mangled in the library
53188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
53198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
53208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
53218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
53228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
53238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SymbolInfo{$Version}{$InfoId}{"Lang"} ne "C")
53248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # all C++ functions are not mangled in the TU dump
53258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Incorrect = 1;
53268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
53278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
53288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Incorrect)
53298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
53308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(link_symbol($SymbolInfo{$Version}{$InfoId}{"ShortName"}, $Version, "-Deps")) {
53318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"MnglName"} = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
53328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
53338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
53348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
53351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # can't detect symbol name
53371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId});
5338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
5339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5340989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $SymbolInfo{$Version}{$InfoId}{"Constructor"}
5341a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    and my $Spec = getVirtSpec($Orig))
5342989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # identify virtual and pure virtual functions
5343989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: constructors cannot be virtual
5344989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # NOTE: in GCC 4.7 D1 destructors have no virtual spec
5345989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko      # in the TU dump, so taking it from the original symbol
5346989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not ($SymbolInfo{$Version}{$InfoId}{"Destructor"}
5347989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        and $SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/D2E/))
5348989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        { # NOTE: D2 destructors are not present in a v-table
5349989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{$Spec} = 1;
5350989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(isInline($InfoId)) {
53531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"InLine"} = 1;
5354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
535582bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko    if(hasThrow($InfoId)) {
5356e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Throw"} = 1;
5357e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
53581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
53591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"})
5360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $SymbolInfo{$Version}{$InfoId}{"InLine"}
5362b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko        and not $SymbolInfo{$Version}{$InfoId}{"Artificial"})
5363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # inline or auto-generated constructor
536462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$Version}{$ClassId}{"Copied"});
5365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5367850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Symbol = $SymbolInfo{$Version}{$InfoId}{"MnglName"})
5368850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
5369570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $ExtraDump)
5370570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
5371570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not selectSymbol($Symbol, $SymbolInfo{$Version}{$InfoId}, "Dump", $Version))
5372570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # non-target symbols
5373570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5374570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return;
5375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
5376850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
5377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Method"
53791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Constructor"}
53801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}
53811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Class"})
5382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"MnglName"}!~/\A(_Z|\?)/)
53849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
53851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
53891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"})
5390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
53911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # one instance for one mangled name only
53931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$Version}{$InfoId});
5394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
5395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
53971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $MangledNames{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}} = 1;
5398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
54001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"Constructor"}
54011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $SymbolInfo{$Version}{$InfoId}{"Destructor"}) {
54021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        delete($SymbolInfo{$Version}{$InfoId}{"Return"});
5403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
54041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/
54051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and $SymbolInfo{$Version}{$InfoId}{"Class"})
5406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
54071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$Version}{$InfoId}{"Type"} eq "Function")
5408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # static methods
54091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
54121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getFuncLink($InfoId) eq "Static") {
54131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Static"} = 1;
5414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5415dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A(_Z|\?)/)
5416dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5417dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $Unmangled = $tr_name{$SymbolInfo{$Version}{$InfoId}{"MnglName"}})
5418dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
54199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Unmangled=~/\.\_\d/)
54209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
5421dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                delete($SymbolInfo{$Version}{$InfoId});
5422dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return;
5423dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5424dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5426f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
54271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(V|)K/) {
54281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
54301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SymbolInfo{$Version}{$InfoId}{"MnglName"}=~/\A_ZN(K|)V/) {
54311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
543307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
543407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($WeakSymbols{$Version}{$SymbolInfo{$Version}{$InfoId}{"MnglName"}}) {
543507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Weak"} = 1;
543607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
543774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
543874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump) {
543974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Header"} = guessHeader($InfoId);
544074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
544174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
544274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
544374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub guessHeader($)
544474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
544574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
544674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ShortName = $SymbolInfo{$Version}{$InfoId}{"ShortName"};
544774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassId = $SymbolInfo{$Version}{$InfoId}{"Class"};
544874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $ClassName = $ClassId?get_ShortClass($ClassId, $Version):"";
544974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Header = $SymbolInfo{$Version}{$InfoId}{"Header"};
545074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $HPath = $SymbolHeader{$Version}{$ClassName}{$ShortName})
545174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
545274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(get_filename($HPath) eq $Header)
545374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
545474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $HDir = get_filename(get_dirname($HPath));
545574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($HDir ne "include"
545674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $HDir=~/\A[a-z]+\Z/i) {
545774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HDir, $Header);
545874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
545974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
546074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
546174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Header;
5462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isInline($)
5465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # "body: undefined" in the tree
5466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # -fkeep-inline-functions GCC option should be specified
5467dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5468dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5469dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ undefined /i) {
5470dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return 0;
5471dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
5474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5476e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub hasThrow($)
5477e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5478e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5479e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5480e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5481e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return getTreeAttr_Unql($1, "unql");
5482e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5483e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5484e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return 1;
5485e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5486e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
5487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeId($)
5488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5489dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5490dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5491dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
5492dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5493dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5495dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
5496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeMemb($$)
5499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeType = $TypeAttr->{"Type"};
55020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Pos, $UnnamedPos) = (0, 0);
550374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $StaticFields = 0;
5504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeType eq "Enum")
5505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
55064b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Csts($TypeId);
55074b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
55094b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"value"} = getEnumMembVal($MInfoId);
55104b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembName = getTreeStr(getTreeAttr_Purp($MInfoId));
551162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $MembName;
55124b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $EnumMembName_Id{$Version}{getTreeAttr_Valu($MInfoId)} = ($TypeAttr->{"NameSpace"})?$TypeAttr->{"NameSpace"}."::".$MembName:$MembName;
55134b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
55140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypeType=~/\A(Struct|Class|Union)\Z/)
5518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
55194b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $MInfoId = getTreeAttr_Flds($TypeId);
55204b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        while($MInfoId)
5521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
55224b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $IType = $LibInfo{$Version}{"info_type"}{$MInfoId};
55234b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MInfo = $LibInfo{$Version}{"info"}{$MInfoId};
5524989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(not $IType or $IType ne "field_decl")
5525989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            { # search for fields, skip other stuff in the declaration
552674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
552774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($IType eq "var_decl")
552874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # static field
552974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $StaticFields = 1;
553074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
553174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
55324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
55354b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $StructMembName = getTreeStr(getTreeAttr_Name($MInfoId));
5536fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(index($StructMembName, "_vptr.")==0)
55371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # virtual tables
5538fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $StructMembName = "_vptr";
5539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields
554201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($TypeAttr->{"Name"}, "_type_info_pseudo")==-1)
5543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
55444b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    my $UnnamedTid = getTreeAttr_Type($MInfoId);
5545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $UnnamedTName = getNameByInfo(getTypeDeclId($UnnamedTid));
5546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isAnon($UnnamedTName))
5547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # rename unnamed fields to unnamed0, unnamed1, ...
5548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $StructMembName = "unnamed".($UnnamedPos++);
5549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
5550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
5551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $StructMembName)
5553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unnamed fields and base classes
55544b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                $MInfoId = getNextElem($MInfoId);
5555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
5556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
55574b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            my $MembTypeId = getTreeAttr_Type($MInfoId);
555862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $MissedTypedef{$Version}{$MembTypeId})
555962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
556062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $AddedTid = $MissedTypedef{$Version}{$MembTypeId}{"Tid"}) {
556162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $MembTypeId = $AddedTid;
556262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
5563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5564177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
55650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"type"} = $MembTypeId;
55660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $TypeAttr->{"Memb"}{$Pos}{"name"} = $StructMembName;
55674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if((my $Access = getTreeAccess($MInfoId)) ne "public")
55681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # marked only protected and private, public by default
55690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"access"} = $Access;
55700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
55710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($MInfo=~/spec:\s*mutable /)
55720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # mutable fields
55730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"mutable"} = 1;
5574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
55754b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $Algn = getAlgn($MInfoId)) {
5576f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"algn"} = $Algn;
5577f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
55784b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my $BFSize = getBitField($MInfoId))
5579f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bits
55800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $TypeAttr->{"Memb"}{$Pos}{"bitfield"} = $BFSize;
5581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
5583f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # in bytes
5584177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if($TypeAttr->{"Memb"}{$Pos}{"algn"}==1)
5585177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                { # template
5586177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    delete($TypeAttr->{"Memb"}{$Pos}{"algn"});
5587177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5588177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                else {
5589177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeAttr->{"Memb"}{$Pos}{"algn"} /= $BYTE_SIZE;
5590177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
5591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5592f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
55934b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            $MInfoId = getNextElem($MInfoId);
55940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Pos += 1;
5595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
559774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
559874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $StaticFields;
5599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncParams($)
5602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
56031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $InfoId = $_[0];
560462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamInfoId = getTreeAttr_Args($InfoId);
5605f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5606f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5607f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5608f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check type of "this" pointer
561062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjectTypeId = getTreeAttr_Type($ParamInfoId);
561162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ObjectName = $TypeInfo{$Version}{$ObjectTypeId}{"Name"})
5612850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
561362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bconst(| volatile)\*const\b/) {
5614850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Const"} = 1;
5615850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
561662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($ObjectName=~/\bvolatile\b/) {
5617850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Volatile"} = 1;
5618850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
5619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5620850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else
5621850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # skip
5622850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
5623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5624ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # skip "this"-parameter
5625ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        # $ParamInfoId = getNextElem($ParamInfoId);
5626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5627f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos, $Vtt_Pos) = (0, 0, -1);
5628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamInfoId)
56290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # formal args
563062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Type($ParamInfoId);
563162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamName = getTreeStr(getTreeAttr_Name($ParamInfoId));
563262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $ParamName)
563362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # unnamed
5634f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $ParamName = "p".($PPos+1);
5635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
563662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $MissedTypedef{$Version}{$ParamTypeId})
563762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
563862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $AddedTid = $MissedTypedef{$Version}{$ParamTypeId}{"Tid"}) {
563962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ParamTypeId = $AddedTid;
564062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
564162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
564262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PType = $TypeInfo{$Version}{$ParamTypeId}{"Type"};
5643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $PType or $PType eq "Unknown") {
5644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
5645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
564662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $PTName = $TypeInfo{$Version}{$ParamTypeId}{"Name"};
5647989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $PTName) {
5648989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return 1;
5649989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5650989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($PTName eq "void") {
5651989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            last;
5652989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
5653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ParamName eq "__vtt_parm"
565462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void const**")
5655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
56560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Vtt_Pos = $Pos;
5657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamInfoId = getNextElem($ParamInfoId);
5658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
56600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
5661177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
5662177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my %Base = get_BaseType($ParamTypeId, $Version))
5663177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
5664177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Base{"Template"}) {
5665177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
5666177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
5667177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5668177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
56690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = $ParamName;
567062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Algn = getAlgn($ParamInfoId)) {
567162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"algn"} = $Algn/$BYTE_SIZE;
567262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
5673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibInfo{$Version}{"info"}{$ParamInfoId}=~/spec:\s*register /)
5674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # foo(register type arg)
56750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"reg"} = 1;
5676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamInfoId = getNextElem($ParamInfoId);
56780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5679f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($ParamName ne "this" or $FType ne "Method") {
5680f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5681f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
5682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
56830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(setFuncArgs($InfoId, $Vtt_Pos)) {
568401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = "-1";
5685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
5687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
56890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub setFuncArgs($$)
5690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
56911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($InfoId, $Vtt_Pos) = @_;
56921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $FuncTypeId = getFuncTypeId($InfoId);
569362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ParamListElemId = getTreeAttr_Prms($FuncTypeId);
5694f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $FType = getFuncType($InfoId);
5695f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
5696f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($FType eq "Method")
5697f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
5698f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        # skip "this"-parameter
569946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        # $ParamListElemId = getNextElem($ParamListElemId);
5700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
57010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $ParamListElemId)
57020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # foo(...)
57030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
57040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
5705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HaveVoid = 0;
5706f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $PPos) = (0, 0);
5707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($ParamListElemId)
57080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # actual params: may differ from formal args
57090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # formal int*const
57100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko      # actual: int*
57110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($Vtt_Pos!=-1 and $Pos==$Vtt_Pos)
5712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
5713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Vtt_Pos=-1;
5714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamListElemId = getNextElem($ParamListElemId);
5715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
5716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
571762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = getTreeAttr_Valu($ParamListElemId);
571862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$Version}{$ParamTypeId}{"Name"} eq "void")
5719dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $HaveVoid = 1;
5721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
5722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
572346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        else
5724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
572546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            if(not defined $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
572646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
572746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
572846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                if(not $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"})
572946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # unnamed
5730f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"name"} = "p".($PPos+1);
573146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
573246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            }
573346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            elsif(my $OldId = $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"})
573446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko            {
5735e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if($Pos>0 or getFuncType($InfoId) ne "Method")
573646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                { # params
573746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    if($OldId ne $ParamTypeId)
573846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    {
573946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %Old_Pure = get_PureType($OldId, $TypeInfo{$Version});
574046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        my %New_Pure = get_PureType($ParamTypeId, $TypeInfo{$Version});
574146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko
574246bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($Old_Pure{"Name"} ne $New_Pure{"Name"}) {
574346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"type"} = $ParamTypeId;
574446bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
574546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                    }
574646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                }
57470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
57480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
574962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $PurpId = getTreeAttr_Purp($ParamListElemId))
57500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # default arguments
575101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $PurpType = $LibInfo{$Version}{"info_type"}{$PurpId})
575201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
57538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($PurpType eq "nop_expr")
57548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # func ( const char* arg = (const char*)(void*)0 )
57558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $PurpId = getTreeAttr_Op($PurpId);
57568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
575701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                my $Val = getInitVal($PurpId, $ParamTypeId);
575801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(defined $Val) {
575901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $SymbolInfo{$Version}{$InfoId}{"Param"}{$Pos}{"default"} = $Val;
576001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
5761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
5762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ParamListElemId = getNextElem($ParamListElemId);
5764f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Pos!=0 or $FType ne "Method") {
5765f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $PPos += 1;
5766f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
57670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Pos += 1;
5768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
57690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ($Pos>=1 and not $HaveVoid);
5770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
577262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chan($)
577362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
577462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
577562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
577662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chan[ ]*:[ ]*@(\d+) /) {
577762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
577862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
577962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
578062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
578162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
578262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
578362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Chain($)
578462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
578562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
578662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
578762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/chain[ ]*:[ ]*@(\d+) /) {
578862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
578962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
579062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
579162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
579262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
579362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5794e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenkosub getTreeAttr_Unql($)
5795e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko{
5796e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5797e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    {
5798e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Info=~/unql[ ]*:[ ]*@(\d+) /) {
5799e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            return $1;
5800e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        }
5801e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
5802e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    return "";
5803e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko}
5804e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko
580562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Scpe($)
580662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
580762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
580862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
580962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/scpe[ ]*:[ ]*@(\d+) /) {
581062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
581162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
581262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
581362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
581462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
581562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
581662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Type($)
581762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
581862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
581962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
582062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /) {
582162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
582262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
582362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
582462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
582562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
582662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
582762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Name($)
582862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
582962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
583062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
583162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /) {
583262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
583362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
583462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
583562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
583662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
583762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
583862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Mngl($)
583962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
584062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
584162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
584262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/mngl[ ]*:[ ]*@(\d+) /) {
584362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
584462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
584562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
584662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
584762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
584862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
584962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Prms($)
585062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
585162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
585262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
585362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/prms[ ]*:[ ]*@(\d+) /) {
585462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
585562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
585662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
585762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
585862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
585962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
586062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Fncs($)
5861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5862dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5863dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
586462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/fncs[ ]*:[ ]*@(\d+) /) {
586562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
586662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
586762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
586862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
586962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
587062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
587162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Csts($)
587262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
587362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
587462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
587562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/csts[ ]*:[ ]*@(\d+) /) {
587662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
587762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
587862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
587962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
588062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
588162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
588262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Purp($)
588362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
588462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
588562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
588662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/purp[ ]*:[ ]*@(\d+) /) {
588762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
588862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
588962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
589062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
589162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
589262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
58938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getTreeAttr_Op($)
58948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
58958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
58968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
58978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Info=~/op 0[ ]*:[ ]*@(\d+) /) {
58988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return $1;
58998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
59008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
59018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return "";
59028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
59038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
590462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Valu($)
590562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
590662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
590762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
590862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*@(\d+) /) {
590962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
591062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
591162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
591262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
591362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
591462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
591562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Flds($)
591662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
591762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
591862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
591962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/flds[ ]*:[ ]*@(\d+) /) {
592062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $1;
592162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
592262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
592362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
592462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
592562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
5926177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getTreeAttr_Binf($)
5927177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
5928177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5929177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
5930177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Info=~/binf[ ]*:[ ]*@(\d+) /) {
5931177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $1;
5932177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
5933177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
5934177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return "";
5935177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
5936177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
593762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getTreeAttr_Args($)
593862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
593962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
594062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
594162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Info=~/args[ ]*:[ ]*@(\d+) /) {
5942dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5943dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeValue($)
5949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5950dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5951dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
5952dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/low[ ]*:[ ]*([^ ]+) /) {
5953dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
5954dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
5957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeAccess($)
5960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5961dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
5962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
5963dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/accs[ ]*:[ ]*([a-zA-Z]+) /)
5964dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
5965dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            my $Access = $1;
5966dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Access eq "prot") {
5967dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "protected";
5968dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5969dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($Access eq "priv") {
5970dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                return "private";
5971dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
5972dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
5973dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ protected /)
5974dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "protected";
5976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5977dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ private /)
5978dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
5979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "private";
5980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
5981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "public";
5983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncAccess($)
5986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
59871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Access = getTreeAccess($_[0]);
5988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
59891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Protected"} = 1;
5990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
59921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SymbolInfo{$Version}{$_[0]}{"Private"} = 1;
5993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
5994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
5995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
5996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setTypeAccess($$)
5997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
5998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $TypeAttr) = @_;
5999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Access = getTreeAccess($TypeId);
6000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Access eq "protected") {
6001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Protected"} = 1;
6002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Access eq "private") {
6004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TypeAttr->{"Private"} = 1;
6005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setFuncKind($)
6009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6010dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6011dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6012dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/pseudo tmpl/) {
6013dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"PseudoTemplate"} = 1;
6014dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6015dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ constructor /) {
6016dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Constructor"} = 1;
6017dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6018dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ destructor /) {
6019dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $SymbolInfo{$Version}{$_[0]}{"Destructor"} = 1;
6020dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6024989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub getVirtSpec($)
6025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6026dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6027dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6028dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/spec[ ]*:[ ]*pure /) {
6029dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
6030dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6031dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/spec[ ]*:[ ]*virt /) {
6032dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
6033dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6034dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ pure\s+virtual /)
6035dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
6036dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "PureVirt";
6037dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6038dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/ virtual /)
6039dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # support for old GCC versions
6040dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Virt";
6041dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncLink($)
6047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6048dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6049dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6050dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/link[ ]*:[ ]*static /) {
6051dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return "Static";
6052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6053dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        elsif($Info=~/link[ ]*:[ ]*([a-zA-Z]+) /) {
6054dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6057dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
606074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Symbol_NS($$)
6061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
606274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
606374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "" if(not $Symbol or not $LibVersion);
606474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $NS = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
606574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $NS)
606674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
606774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(my $Class = $CompleteSignature{$LibVersion}{$Symbol}{"Class"}) {
606874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $NS = $TypeInfo{$LibVersion}{$Class}{"NameSpace"};
606974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
6070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
607174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($NS)
6072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
607374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
607474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
607574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
607674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
6077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
607874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
607974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
608074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
608174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
608274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
6083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
608674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
608774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
6088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
609074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub select_Type_NS($$)
6091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
6093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeName or not $LibVersion);
609474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NS = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$TypeName}}{"NameSpace"})
6095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
609674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
609774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $NS;
609874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
609974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
6100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
610174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            while($NS=~s/::[^:]+\Z//)
610274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
610374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(defined $NestedNameSpaces{$LibVersion}{$NS}) {
610474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    return $NS;
610574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
6106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
610974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return "";
6110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameSpace($)
6113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
611474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $InfoId = $_[0];
611574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(my $NSInfoId = getTreeAttr_Scpe($InfoId))
6116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
611762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $InfoType = $LibInfo{$Version}{"info_type"}{$NSInfoId})
6118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
611962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($InfoType eq "namespace_decl")
6120dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
612162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($LibInfo{$Version}{"info"}{$NSInfoId}=~/name[ ]*:[ ]*@(\d+) /)
612262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
612362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $NameSpace = getTreeStr($1);
612462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($NameSpace eq "::")
612562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # global namespace
612662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "";
612762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
612862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BaseNameSpace = getNameSpace($NSInfoId)) {
612962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $NameSpace = $BaseNameSpace."::".$NameSpace;
613062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
613162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $NestedNameSpaces{$Version}{$NameSpace} = 1;
613262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return $NameSpace;
613362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
613462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
613562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return "";
6136dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6138177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            elsif($InfoType ne "function_decl")
613962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # inside data type
614062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($Name, $NameNS) = getTrivialName(getTypeDeclId($NSInfoId), $NSInfoId);
614162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Name;
614262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
6143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6145dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getEnumMembVal($)
6149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6150dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6152dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/valu[ ]*:[ ]*\@(\d+)/)
6153dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
6154dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $VInfo = $LibInfo{$Version}{"info"}{$1})
6155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
6156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($VInfo=~/cnst[ ]*:[ ]*\@(\d+)/)
6157dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # in newer versions of GCC the value is in the "const_decl->cnst" node
6158dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6159dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6160dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                else
6161dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # some old versions of GCC (3.3) have the value in the "integer_cst" node
6162dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    return getTreeValue($1);
6163dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
6164dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
6168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSize($)
6171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6172dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6173dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6174dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/size[ ]*:[ ]*\@(\d+)/) {
6175dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getTreeValue($1);
6176dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6178dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAlgn($)
6182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6183dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6184dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6185dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/algn[ ]*:[ ]*(\d+) /) {
6186dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return $1;
6187dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6189dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6192f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getBitField($)
6193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6194dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
6195dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
6196dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/ bitfield /) {
6197dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            return getSize($_[0]);
6198dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
6199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6200dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return 0;
6201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
620362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getNextElem($)
6204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
620562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Chan = getTreeAttr_Chan($_[0])) {
620662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chan;
6207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
620862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif(my $Chain = getTreeAttr_Chain($_[0])) {
620962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Chain;
6210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6211dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
6212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
621462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub registerHeader($$)
621562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # input: absolute path of header, relative path or name
6216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
621762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
621862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
6219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
622062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
622162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
622262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$Header\'");
6223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
622462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(skipHeader($Header, $LibVersion))
622562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # skip
6226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
6227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
622862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $Header_Path = identifyHeader($Header, $LibVersion))
622962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
623062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        detect_header_includes($Header_Path, $LibVersion);
623162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
62328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(defined $Tolerance and $Tolerance=~/3/)
62338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # 3 - skip headers that include non-Linux headers
62348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($OSgroup ne "windows")
62358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
62368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Inc (keys(%{$Header_Includes{$LibVersion}{$Header_Path}}))
62378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
62388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(specificHeader($Inc, "windows")) {
62398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        return "";
62408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
62418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
62428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
62438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
62448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
624562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RHeader_Path = $Header_ErrorRedirect{$LibVersion}{$Header_Path})
624662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # redirect
624762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Registered_Headers{$LibVersion}{$RHeader_Path}{"Identity"}
624862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            or skipHeader($RHeader_Path, $LibVersion))
624962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # skip
625062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return "";
625162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
625262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Header_Path = $RHeader_Path;
625362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
625462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Header_ShouldNotBeUsed{$LibVersion}{$Header_Path})
625562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # skip
625662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return "";
625762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
625862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
625962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HName = get_filename($Header_Path))
626062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # register
626162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Registered_Headers{$LibVersion}{$Header_Path}{"Identity"} = $HName;
626262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HeaderName_Paths{$LibVersion}{$HName}{$Header_Path} = 1;
626362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
626462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
626562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(($Header=~/\.(\w+)\Z/ and $1 ne "h")
626662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Header!~/\.(\w+)\Z/)
62678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # hpp, hh, etc.
626862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            setLanguage($LibVersion, "C++");
62698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CPP_HEADERS = 1;
627062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
627162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
627262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CheckHeadersOnly
627362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Header=~/(\A|\/)c\+\+(\/|\Z)/)
627462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # /usr/include/c++/4.6.1/...
627562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $STDCXX_TESTING = 1;
627662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
627762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
627862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header_Path;
6279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
628062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
6281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
62838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub registerDir($$$)
6284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $WithDeps, $LibVersion) = @_;
6286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//g;
6287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not $Dir or not -d $Dir);
6288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir = get_abs_path($Dir);
6289f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
6290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Mode = "All";
6291850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($WithDeps)
6292850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}) {
6294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RegisteredDirs{$LibVersion}{$Dir}{0}) {
6297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Mode = "DepsOnly";
6298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6300850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
6301850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($RegisteredDirs{$LibVersion}{$Dir}{1}
6303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $RegisteredDirs{$LibVersion}{$Dir}{0}) {
6304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return;
6305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Header_Dependency{$LibVersion}{$Dir} = 1;
6308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $RegisteredDirs{$LibVersion}{$Dir}{$WithDeps} = 1;
6309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Mode eq "DepsOnly")
6310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6311570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (cmd_find($Dir,"d")) {
6312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Dependency{$LibVersion}{$Path} = 1;
6313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
6315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6316570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (sort {length($b)<=>length($a)} cmd_find($Dir,"f"))
6317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($WithDeps)
6319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $SubDir = $Path;
6321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while(($SubDir = get_dirname($SubDir)) ne $Dir)
6322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # register all sub directories
6323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Dependency{$LibVersion}{$SubDir} = 1;
6324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(is_not_header($Path));
6327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
6328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Neighbors
63299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $Part (get_prefixes($Path)) {
6330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Include_Neighbors{$LibVersion}{$Part} = $Path;
6331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_filename($Dir) eq "include")
6334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for "lib/include/" directory
6335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $LibDir = $Dir;
6336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibDir=~s/([\/\\])include\Z/$1lib/g and -d $LibDir) {
63378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($LibDir, $WithDeps, $LibVersion);
6338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_redirect($$$)
6343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path, $LibVersion) = @_;
6345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Errors = ();
6346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Content=~s/#\s*error\s+([^\n]+?)\s*(\n|\Z)//) {
6347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Errors, $1);
6348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Redirect = "";
6350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Errors)
6351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        s/\s{2,}/ /g;
6353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/(only|must\ include
6354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |update\ to\ include
6355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ with
6356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        |replaced\ by|renamed\ to
63579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        |\ is\ in|\ use)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))/ix)
6358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/(include|use|is\ in)\ (<[^<>]+>|[\w\-\/\\]+\.($HEADER_EXT))\ instead/i)
6363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Redirect = $2;
6365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            last;
6366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(/this\ header\ should\ not\ be\ used
6368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |programs\ should\ not\ directly\ include
6369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |you\ should\ not\ (include|be\ (including|using)\ this\ (file|header))
6370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |is\ not\ supported\ API\ for\ general\ use
6371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |do\ not\ use
63729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko         |should\ not\ be\ (used|using)
6373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko         |cannot\ be\ included\ directly/ix and not /\ from\ /i) {
6374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
6375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6377850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Redirect)
6378850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6379850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/\A<//g;
6380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Redirect=~s/>\Z//g;
6381850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6382850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return $Redirect;
6383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_includes($$)
6386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Path) = @_;
6388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Includes = ();
638974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]*([<"].+?[">])[ \t]*//m)
6390850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # C/C++: include, Objective C/C++: import directive
63914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        my $Header = $2;
639274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $Method = substr($Header, 0, 1, "");
639374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        substr($Header, length($Header)-1, 1, "");
639474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Header = path_format($Header, $OSgroup);
639574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Method eq "\"" or is_abs($Header))
639674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
639774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(-e join_P(get_dirname($Path), $Header))
639874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # relative path exists
639974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = -1;
6400850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
640174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            else
640274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # include "..." that doesn't exist is equal to include <...>
640374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Includes{$Header} = 2;
6404850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
640674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else {
640774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$Header} = 1;
640874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
640974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
641074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
641174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
641274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        while($Content=~s/^[ \t]*#[ \t]*(include|include_next|import)[ \t]+(\w+)[ \t]*//m)
641374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # FT_FREETYPE_H
641474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Includes{$2} = 0;
6415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Includes;
6418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub ignore_path($)
6421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/\~\Z/)
6424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping system backup files
6425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Path=~/(\A|[\/\\]+)(\.(svn|git|bzr|hg)|CVS)([\/\\]+|\Z)/)
6428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# skipping hidden .svn, .git, .bzr, .hg and CVS directories
6429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
64349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortByWord($$)
6435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $W) = @_;
6437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(length($W)<2);
6438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_filename($b)=~/\Q$W\E/i<=>get_filename($a)=~/\Q$W\E/i} @{$ArrRef};
6439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
64419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub sortHeaders($$)
6442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($H1, $H2) = @_;
64448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H1=~s/\.[a-z]+\Z//ig;
6446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $H2=~s/\.[a-z]+\Z//ig;
64478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
64488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname1 = get_filename($H1);
64498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Hname2 = get_filename($H2);
64508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir1 = get_dirname($H1);
64518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HDir2 = get_dirname($H2);
6452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname1 = get_filename($HDir1);
6453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dirname2 = get_filename($HDir2);
64548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
64558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir1=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
64568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $HDir2=~s/\A.*[\/\\]+([^\/\\]+[\/\\]+[^\/\\]+)\Z/$1/;
64578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
64589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[0] eq $_[1]
64599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    or $H1 eq $H2) {
6460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
6461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H1=~/\A\Q$H2\E/) {
6463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($H2=~/\A\Q$H1\E/) {
6466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir1=~/\Q$Hname1\E/i
6469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir2!~/\Q$Hname2\E/i)
64709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($HDir2=~/\Q$Hname2\E/i
6474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $HDir1!~/\Q$Hname1\E/i)
64759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/glib-2.0/glib.h
6476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname1=~/\Q$Dirname1\E/i
6479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname2!~/\Q$Dirname2\E/i)
64809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Hname2=~/\Q$Dirname2\E/i
6484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Hname1!~/\Q$Dirname1\E/i)
64859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/hildon-thumbnail/hildon-thumbnail-factory.h
6486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname1=~/(config|lib|util)/i
64899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname2!~/(config|lib|util)/i)
64909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1;
6492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    elsif($Hname2=~/(config|lib|util)/i
64949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    and $Hname1!~/(config|lib|util)/i)
64959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # include/alsa/asoundlib.h
6496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
6497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
64989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else
64999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
65008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R1 = checkRelevance($H1);
65018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $R2 = checkRelevance($H2);
65028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($R1 and not $R2)
65038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
65048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return -1;
65058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
65068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        elsif($R2 and not $R1)
65078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # libebook/e-book.h
65088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
65098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
65108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
65118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
65128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return (lc($H1) cmp lc($H2));
65138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
6514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub searchForHeaders($)
6518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
6520570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # gcc standard include paths
6522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    registerGccHeaders();
6523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" and not $STDCXX_TESTING)
6525570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # c++ standard include paths
6526570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        registerCppHeaders();
6527570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6528570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # processing header paths
6530570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$Descriptor{$LibVersion}{"IncludePaths"}},
6531570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    @{$Descriptor{$LibVersion}{"AddIncludePaths"}})
6532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IPath = $Path;
6534a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($SystemRoot)
6535a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
6536a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(is_abs($Path)) {
6537a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Path = $SystemRoot.$Path;
6538a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
6539a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        }
6540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Path) {
6541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Path\'");
6542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path) {
6544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "\'$Path\' - not a directory");
6545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Path)
6547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = get_abs_path($Path);
65498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 0, $LibVersion);
6550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(grep {$IPath eq $_} @{$Descriptor{$LibVersion}{"AddIncludePaths"}}) {
6551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Add_Include_Paths{$LibVersion}}, $Path);
6552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
6554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@{$Include_Paths{$LibVersion}}, $Path);
6555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$Include_Paths{$LibVersion}}) {
6559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $INC_PATH_AUTODETECT{$LibVersion} = 0;
6560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering directories
6563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -e $Path);
6566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
6567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
6568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path) {
65698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            registerDir($Path, 1, $LibVersion);
6570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-f $Path)
6572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($Path);
6574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not grep { $Dir eq $_ } (@{$SystemPaths{"include"}})
6575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $LocalIncludes{$Dir})
6576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
65778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                registerDir($Dir, 1, $LibVersion);
6578fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # if(my $OutDir = get_dirname($Dir))
6579fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # { # registering the outer directory
6580fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     if(not grep { $OutDir eq $_ } (@{$SystemPaths{"include"}})
6581fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     and not $LocalIncludes{$OutDir}) {
6582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #         registerDir($OutDir, 0, $LibVersion);
6583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                #     }
6584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # }
6585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6588850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6589850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6590850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %RegisteredDirs = ();
6591850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # registering headers
6593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Position = 0;
6594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Headers"}))
6595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Dest) and not -e $Dest) {
6597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
6598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest = path_format($Dest, $OSgroup);
6600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_header($Dest, 1, $LibVersion))
6601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
660262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HPath = registerHeader($Dest, $LibVersion)) {
6603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$HPath}{"Pos"} = $Position++;
6604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(-d $Dest)
6607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Registered = ();
6609570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"f"))
6610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
6612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(not is_header($Path, 0, $LibVersion));
661362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $HPath = registerHeader($Path, $LibVersion)) {
6614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Registered, $HPath);
6615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
66179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            @Registered = sort {sortHeaders($a, $b)} @Registered;
66189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            sortByWord(\@Registered, $TargetLibraryShortName);
6619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (@Registered) {
6620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Registered_Headers{$LibVersion}{$Path}{"Pos"} = $Position++;
6621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
6624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't identify \'$Dest\' as a header file");
6625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
66278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
66288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/4/)
66298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 4 - skip headers included by others
66308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Path (keys(%{$Registered_Headers{$LibVersion}}))
66318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
6632fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Header_Includes_R{$LibVersion}{$Path}) {
66338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($Registered_Headers{$LibVersion}{$Path});
66348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
66358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
66368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
66378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
6638dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(my $HList = $Descriptor{$LibVersion}{"IncludePreamble"})
6639dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # preparing preamble headers
6640dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, $HList))
6641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6642dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(is_abs($Header) and not -f $Header) {
6643dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$Header\'");
6644dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6645dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $Header = path_format($Header, $OSgroup);
6646dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $Header_Path = is_header($Header, 1, $LibVersion))
6647dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
664862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                next if(skipHeader($Header_Path, $LibVersion));
6649570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($Include_Preamble{$LibVersion}, $Header_Path);
6650dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6651dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else {
6652dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                exitStatus("Access_Error", "can't identify \'$Header\' as a header file");
6653dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
6654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Header_Name (keys(%{$HeaderName_Paths{$LibVersion}}))
6657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # set relative paths (for duplicates)
6658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})>=2)
6659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for duplicates
6660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $FirstPath = (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))[0];
6661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Prefix = get_dirname($FirstPath);
6662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            while($Prefix=~/\A(.+)[\/\\]+[^\/\\]+\Z/)
6663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # detect a shortest distinguishing prefix
6664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $NewPrefix = $1;
6665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my %Identity = ();
6666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
6668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Path=~/\A\Q$Prefix\E[\/\\]+(.*)\Z/) {
6669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Identity{$Path} = $1;
6670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(keys(%Identity)==keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}}))
6673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # all names are differend with current prefix
6674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Path (keys(%{$HeaderName_Paths{$LibVersion}{$Header_Name}})) {
6675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Registered_Headers{$LibVersion}{$Path}{"Identity"} = $Identity{$Path};
6676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
6677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
6678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
6679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Prefix = $NewPrefix; # increase prefix
6680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6683850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6684850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
6685850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %HeaderName_Paths = ();
6686850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (keys(%{$Include_Order{$LibVersion}}))
6688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ordering headers according to descriptor
66898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $PairName = $Include_Order{$LibVersion}{$HeaderName};
6690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Pos, $PairPos) = (-1, -1);
6691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Path, $PairPath) = ();
6692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = keys(%{$Registered_Headers{$LibVersion}});
6693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        @Paths = sort {int($Registered_Headers{$LibVersion}{$a}{"Pos"})<=>int($Registered_Headers{$LibVersion}{$b}{"Pos"})} @Paths;
6694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header_Path (@Paths)
6695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $PairName)
6697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $PairPath = $Header_Path;
6700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_filename($Header_Path) eq $HeaderName)
6702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
6703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Pos = $Registered_Headers{$LibVersion}{$Header_Path}{"Pos"};
6704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path = $Header_Path;
6705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PairPos!=-1 and $Pos!=-1
6708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and int($PairPos)<int($Pos))
6709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Tmp = %{$Registered_Headers{$LibVersion}{$Path}};
6711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$Path}} = %{$Registered_Headers{$LibVersion}{$PairPath}};
6712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$Registered_Headers{$LibVersion}{$PairPath}} = %Tmp;
6713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Registered_Headers{$LibVersion}})) {
6716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "header files are not found in the ".$Descriptor{$LibVersion}{"Version"});
6717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_real_includes($$)
6721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $LibVersion or not $AbsPath or not -e $AbsPath);
6724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}
6725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6728850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_real_includes"}{$LibVersion}{$AbsPath}=1;
6729850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = callPreprocessor($AbsPath, "", $LibVersion);
6731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path);
6732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    open(PREPROC, $Path);
6733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(<PREPROC>)
6734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(/#\s+\d+\s+"([^"]+)"[\s\d]*\n/)
6736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Include = path_format($1, $OSgroup);
6738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include=~/\<(built\-in|internal|command(\-|\s)line)\>|\A\./) {
6739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Include eq $AbsPath) {
6742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$Include} = 1;
6745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
6748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_header_includes($$)
6752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
6754850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return if(not $LibVersion or not $Path);
6755850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"detect_header_includes"}{$LibVersion}{$Path}) {
6756850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6757850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $Cache{"detect_header_includes"}{$LibVersion}{$Path}=1;
6759850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6760850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not -e $Path) {
6761850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return;
6762850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
6763850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
6764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($Path);
6765850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Redirect = parse_redirect($Content, $Path, $LibVersion))
6766850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # detect error directive in headers
676762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $RedirectPath = identifyHeader($Redirect, $LibVersion))
6768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath=~/\/usr\/include\// and $Path!~/\/usr\/include\//) {
677062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $RedirectPath = identifyHeader(get_filename($Redirect), $LibVersion);
6771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RedirectPath ne $Path) {
6773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_ErrorRedirect{$LibVersion}{$Path} = $RedirectPath;
6774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
67769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
67779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # can't find
67789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Header_ShouldNotBeUsed{$LibVersion}{$Path} = 1;
67799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
6780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6781850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Inc = parse_includes($Content, $Path))
6782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
6783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Include (keys(%{$Inc}))
6784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # detect includes
6785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Header_Includes{$LibVersion}{$Path}{$Include} = $Inc->{$Include};
67868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
67878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Tolerance and $Tolerance=~/4/)
67888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
67898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my $HPath = identifyHeader($Include, $LibVersion))
67908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
67918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Header_Includes_R{$LibVersion}{$HPath}{$Path} = 1;
67928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
67938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
6794850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
6795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub fromLibc($)
679974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC header
6800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
6801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $Name) = separate_path($Path);
6802fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6803fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6804fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($Dir) eq "libc" and $GlibcHeader{$Name})
6805fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{stdio, ...}.h
6806fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6807fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6811fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Dir eq "/usr/include" and $GlibcHeader{$Name})
6812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{stdio, ...}.h
6813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLibcDir($)
682074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{ # system GLIBC directory
6821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
6822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($OutDir, $Name) = separate_path($Dir);
6823fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($OStarget eq "symbian")
6824fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
6825fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(get_filename($OutDir) eq "libc"
6826fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6827fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # epoc32/include/libc/{sys,bits,asm,asm-*}/*.h
6828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6829fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
6831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
6832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # linux
6833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($OutDir eq "/usr/include"
6834fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and ($Name=~/\Aasm(|-.+)\Z/ or $GlibcDir{$Name}))
6835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # /usr/include/{sys,bits,asm,asm-*}/*.h
6836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
6837fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
6838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
6840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_recursive_includes($$)
6843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
6845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath);
6846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isCyclical(\@RecurInclude, $AbsPath)) {
6847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsDir, $Name) = separate_path($AbsPath);
6850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(isLibcDir($AbsDir))
685174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # system GLIBC internals
685274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return () if(not $ExtraInfo);
6853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}})) {
6855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($OSgroup ne "windows" and $Name=~/windows|win32|win64/i);
6858570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6859570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($MAIN_CPP_DIR and $AbsPath=~/\A\Q$MAIN_CPP_DIR\E/ and not $STDCXX_TESTING)
6860570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # skip /usr/include/c++/*/ headers
6861570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return () if(not $ExtraInfo);
6862570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
6863570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
6864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurInclude, $AbsPath);
6865570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep { $AbsDir eq $_ } @DefaultGccPaths
686674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    or (grep { $AbsDir eq $_ } @DefaultIncPaths and fromLibc($AbsPath)))
6867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check "real" (non-"model") include paths
6868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Paths = detect_real_includes($AbsPath, $LibVersion);
6869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        pop(@RecurInclude);
6870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @Paths;
6871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$Header_Includes{$LibVersion}{$AbsPath}})) {
6873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_header_includes($AbsPath, $LibVersion);
6874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Include (keys(%{$Header_Includes{$LibVersion}{$AbsPath}}))
6876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6877850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $IncType = $Header_Includes{$LibVersion}{$AbsPath}{$Include};
6878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HPath = "";
6879850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType<0)
6880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for #include "..."
688174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P($AbsDir, $Include);
6882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
688374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $HPath = realpath($Candidate);
6884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6886850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($IncType>0
68871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Include=~/[\/\\]/) # and not find_in_defaults($Include)
6888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for the nearest header
6889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # QtCore/qabstractanimation.h includes <QtCore/qobject.h>
689074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Candidate = join_P(get_dirname($AbsDir), $Include);
6891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-f $Candidate) {
6892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $HPath = $Candidate;
6893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HPath) {
689662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $HPath = identifyHeader($Include, $LibVersion);
6897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HPath);
6899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HPath eq $AbsPath) {
6900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
6901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
69029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
69039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Debug)
69049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # boundary headers
690574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             if($HPath=~/vtk/ and $AbsPath!~/vtk/)
690674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             {
690774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#                 print STDERR "$AbsPath -> $HPath\n";
690874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko#             }
69099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
69109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
6911850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RecursiveIncludes{$LibVersion}{$AbsPath}{$HPath} = $IncType;
6912850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($IncType>0)
6913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only include <...>, skip include "..." prefixes
6914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header_Include_Prefix{$LibVersion}{$AbsPath}{$HPath}{get_dirname($Include)} = 1;
6915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $IncPath (detect_recursive_includes($HPath, $LibVersion))
6917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($IncPath eq $AbsPath) {
6919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
6920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6921850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $RIncType = $RecursiveIncludes{$LibVersion}{$HPath}{$IncPath};
6922850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($RIncType==-1)
6923850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # include "..."
6924850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $RIncType = $IncType;
6925850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6926850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($RIncType==2)
6927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
6928850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($IncType!=-1) {
6929850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $RIncType = $IncType;
6930850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
6931850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
6932850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $RecursiveIncludes{$LibVersion}{$AbsPath}{$IncPath} = $RIncType;
6933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$HPath}{$IncPath}})) {
6934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Header_Include_Prefix{$LibVersion}{$AbsPath}{$IncPath}{$Prefix} = 1;
6935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dep (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}}))
6938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
6939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GlibcHeader{get_filename($Dep)} and keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}})>=2
6940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""})
6941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # distinguish math.h from glibc and math.h from the tested library
6942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($Header_Include_Prefix{$LibVersion}{$AbsPath}{$Dep}{""});
6943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                last;
6944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
6945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurInclude);
6948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}});
6949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_framework($$$)
6952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Framework, $LibVersion) = @_;
6954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header or not $Framework or not $LibVersion);
6955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header}) {
6956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header};
6957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dependency (sort {get_depth($a)<=>get_depth($b)} keys(%{$Header_Dependency{$LibVersion}}))
6959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_filename($Dependency) eq $Framework
6961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and -f get_dirname($Dependency)."/".$Header) {
6962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = get_dirname($Dependency));
6963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_framework"}{$LibVersion}{$Framework}{$Header} = "");
6966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_in_defaults($)
6969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Header = $_[0];
6971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Header);
6972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"find_in_defaults"}{$Header}) {
6973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"find_in_defaults"}{$Header};
6974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6975570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultIncPaths,
6976570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultGccPaths,
6977570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @DefaultCppPaths,
6978570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                     @UsersIncPath)
6979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Dir);
6981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Dir."/".$Header) {
6982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ($Cache{"find_in_defaults"}{$Header}=$Dir);
6983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
6984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
6985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"find_in_defaults"}{$Header}="");
6986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
6987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
6988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmp_paths($$)
6989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
6990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path1, $Path2) = @_;
6991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts1 = split(/[\/\\]/, $Path1);
6992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts2 = split(/[\/\\]/, $Path2);
6993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Num (0 .. $#Parts1)
6994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
6995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part1 = $Parts1[$Num];
6996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Part2 = $Parts2[$Num];
6997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GlibcDir{$Part1}
6998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part2}) {
6999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($GlibcDir{$Part2}
7002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $GlibcDir{$Part1}) {
7003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
7004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1=~/glib/
7006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2!~/glib/) {
7007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part1!~/glib/
7010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Part2=~/glib/) {
7011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return -1;
7012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $CmpRes = ($Part1 cmp $Part2)) {
7014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $CmpRes;
7015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
7018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkRelevance($)
7021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
70228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
7023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Path);
70248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot) {
7026a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Path = cut_path_prefix($Path, $SystemRoot);
7027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
70288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
70298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = lc(get_filename($Path));
70308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = lc(get_dirname($Path));
70318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
7032a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $Name=~s/\.\w+\Z//g; # remove extension (.h)
70338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
70348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Token (split(/[_\d\W]+/, $Name))
7035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
70368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Len = length($Token);
70378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if($Len<=1);
70388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Dir=~/(\A|lib|[_\d\W])\Q$Token\E([_\d\W]|lib|\Z)/)
70398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # include/evolution-data-server-1.4/libebook/e-book.h
70408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
70418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
70428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Len>=4 and index($Dir, $Token)!=-1)
7043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # include/gupnp-1.0/libgupnp/gupnp-context.h
7044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
7048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkFamily(@)
7051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Paths = @_;
7053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#Paths<=0);
7054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefix = ();
7055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (@Paths)
7056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
7058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = cut_path_prefix($Path, $SystemRoot);
7059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Dir = get_dirname($Path))
7061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Dir=~s/(\/[^\/]+?)[\d\.\-\_]+\Z/$1/g; # remove version suffix
7063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{$Dir} += 1;
7064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Prefix{get_dirname($Dir)} += 1;
7065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (sort keys(%Prefix))
7068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(get_depth($_)>=3
7070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Prefix{$_}==$#Paths+1) {
7071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
7075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAcceptable($$$)
7078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
7080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
7081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_dirname($Header))
7082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # with prefix
7083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HName=~/config|setup/i and $Candidate=~/[\/\\]lib\d*[\/\\]/)
7086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for glibconfig.h in /usr/lib/glib-2.0/include/
7087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkRelevance($Candidate))
7090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # allow to search for atk.h in /usr/include/atk-1.0/atk/
7091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(checkFamily(getSystemHeaders($HName, $LibVersion)))
7094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # /usr/include/qt4/QtNetwork/qsslconfiguration.h
7095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # /usr/include/qt4/Qt/qsslconfiguration.h
7096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]stdapis[\/\\]/) {
7101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
7102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
7105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRelevant($$$)
7108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # disallow to search for "abstract" headers in too deep directories
7109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $Candidate, $LibVersion) = @_;
7110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $HName = get_filename($Header);
7111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\](tools|stlportv5)[\/\\]/) {
7114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
71179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "bsd")
71189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
7119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate=~/[\/\\]include[\/\\]bsd[\/\\]/)
7120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # openssh: skip /usr/lib/bcc/include/bsd/signal.h
7121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
71249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget ne "windows")
71259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
71269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Candidate=~/[\/\\](wine|msvcrt|windows)[\/\\]/)
71279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # skip /usr/include/wine/msvcrt
71289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return 0;
71299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
71309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
7131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate=~/[\/\\]wx[\/\\]/)
7133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # do NOT search in system /wx/ directory
7134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for headers without a prefix: sstream.h
7135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/c\+\+[\/\\]\d+/ and $MAIN_CPP_DIR
7138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\A\Q$MAIN_CPP_DIR\E/)
7139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip ../c++/3.3.3/ if using ../c++/4.5/
7140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Candidate=~/[\/\\]asm-/
7143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and (my $Arch = getArch($LibVersion)) ne "unknown")
7144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # arch-specific header files
7145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Candidate!~/[\/\\]asm-\Q$Arch\E/)
7146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {# skip ../asm-arm/ if using x86 architecture
7147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = getSystemHeaders($HName, $LibVersion);
7151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#Candidates==1)
7152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique header
7153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SCandidates = getSystemHeaders($Header, $LibVersion);
7156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#SCandidates==1)
7157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unique name
7158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
7159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SystemDepth = $SystemRoot?get_depth($SystemRoot):0;
7161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(get_depth($Candidate)-$SystemDepth>=5)
7162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # abstract headers in too deep directories
7163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # sstream.h or typeinfo.h in /usr/include/wx-2.9/wx/
7164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isAcceptable($Header, $Candidate, $LibVersion)) {
7165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header eq "parser.h"
7169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Candidate!~/\/libxml2\//)
7170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # select parser.h from xml2 library
7171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
7172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not get_dirname($Header)
7174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$SystemHeaders{$HName}})>=3)
7175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # many headers with the same name
7176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # like thread.h included without a prefix
7177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not checkFamily(@Candidates)) {
7178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
7179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
7182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub selectSystemHeader($$)
718562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
718662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"selectSystemHeader"}{$_[1]}{$_[0]}) {
718762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"selectSystemHeader"}{$_[1]}{$_[0]};
718862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
718962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"selectSystemHeader"}{$_[1]}{$_[0]} = selectSystemHeader_I(@_));
719062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
719162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
719262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectSystemHeader_I($$)
7193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
719562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(-f $Header) {
719662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Header;
719762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
719862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(is_abs($Header) and not -f $Header)
719962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # incorrect absolute path
720062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
720162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
72029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $ConfHeaders{lc($Header)})
720362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # too abstract configuration headers
720462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
720562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
72069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $HName = get_filename($Header);
7207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
7208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
72099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $WinHeaders{lc($HName)}
72109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        or $HName=~/windows|win32|win64/i)
721162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # windows headers
7212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
72149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
72159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup ne "macos")
72169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
72179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($HName eq "fp.h")
721874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # pngconf.h includes fp.h in Mac OS
7219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
7220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
722274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
722374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(defined $ObsoleteHeaders{$HName})
722474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # obsolete headers
722574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return "";
7226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
722774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "linux" or $OSgroup eq "bsd")
722807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
722974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(defined $AlienHeaders{$HName}
723074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or defined $AlienHeaders{$Header})
723174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # alien headers from other systems
723207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            return "";
723307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
723407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
723562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7236570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@{$SystemPaths{"include"}})
7237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in default paths
7238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $Path."/".$Header) {
723974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Path,$Header);
7240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7242e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"})
724362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # register all headers in system include dirs
7244e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
7245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort {get_depth($a)<=>get_depth($b)}
7247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    sort {cmp_paths($b, $a)} getSystemHeaders($Header, $LibVersion))
7248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isRelevant($Header, $Candidate, $LibVersion)) {
725062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Candidate;
7251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
725362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # error
725462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSystemHeaders($$)
7258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Candidates = ();
7261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (sort keys(%{$SystemHeaders{$Header}}))
7262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
726362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(skipHeader($Candidate, $LibVersion)) {
7264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
7265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Candidates, $Candidate);
7267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Candidates;
7269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_path_prefix($$)
7272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Prefix) = @_;
7274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path if(not $Prefix);
7275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Prefix=~s/[\/\\]+\Z//;
7276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path=~s/\A\Q$Prefix\E([\/\\]+|\Z)//;
7277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_default_include_dir($)
7281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Dir = $_[0];
7283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Dir=~s/[\/\\]+\Z//;
7284570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return grep { $Dir eq $_ } (@DefaultGccPaths, @DefaultCppPaths, @DefaultIncPaths);
7285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
728762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader($$)
728862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # cache function
7289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
729062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Header) {
729162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "";
7292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
729362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Header=~s/\A(\.\.[\\\/])+//g;
729462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"identifyHeader"}{$LibVersion}{$Header}) {
729562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"identifyHeader"}{$LibVersion}{$Header};
7296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
729762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"identifyHeader"}{$LibVersion}{$Header} = identifyHeader_I($Header, $LibVersion));
7298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
730062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub identifyHeader_I($$)
7301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # search for header by absolute path, relative path or name
7302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $LibVersion) = @_;
7303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header)
7304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # it's relative or absolute path
7305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return get_abs_path($Header);
7306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($GlibcHeader{$Header} and not $GLIBC_TESTING
7308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and my $HeaderDir = find_in_defaults($Header))
7309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for libc headers in the /usr/include
7310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # for non-libc target library before searching
7311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # in the library paths
731274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($HeaderDir,$Header);
7313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $Path = $Include_Neighbors{$LibVersion}{$Header})
7315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the target library paths
7316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Path;
7317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7318570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultGccHeader{$Header})
7319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the internal GCC include paths
7320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultGccHeader{$Header};
7321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7322dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    elsif(my $DefaultDir = find_in_defaults($Header))
7323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default GCC include paths
732474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return join_P($DefaultDir,$Header);
7325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7326570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif(defined $DefaultCppHeader{$Header})
7327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search in the default G++ include paths
7328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $DefaultCppHeader{$Header};
7329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $AnyPath = selectSystemHeader($Header, $LibVersion))
7331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search everywhere in the system
7332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $AnyPath;
7333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
733462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($OSgroup eq "macos")
733562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # search in frameworks: "OpenGL/gl.h" is "OpenGL.framework/Headers/gl.h"
733662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Dir = get_dirname($Header))
733762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
733862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $RelPath = "Headers\/".get_filename($Header);
733962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $HeaderDir = find_in_framework($RelPath, $Dir.".framework", $LibVersion)) {
734074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return join_P($HeaderDir, $RelPath);
734162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
734262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
7343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
734462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # cannot find anything
734562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "";
7346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLocation($)
7349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7350dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7351dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7352dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/srcp[ ]*:[ ]*([\w\-\<\>\.\+\/\\]+):(\d+) /) {
73539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return (path_format($1, $OSgroup), $2);
7354dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
73560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return ();
7357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getNameByInfo($)
7360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7361989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7362dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
7363dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Info=~/name[ ]*:[ ]*@(\d+) /)
7364dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
7365dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $NInfo = $LibInfo{$Version}{"info"}{$1})
7366dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
7367dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($NInfo=~/strg[ ]*:[ ]*(.*?)[ ]+lngt/)
7368dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # short unsigned int (may include spaces)
73698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Str = $1;
73708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($CppMode{$Version}
73718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    and $Str=~/\Ac99_(.+)\Z/)
73728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
73738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($CppKeywords_A{$1}) {
73748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            $Str=$1;
73758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
73768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
73778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return $Str;
7378dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
7379dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
7380dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
7381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7382dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return "";
7383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTreeStr($)
7386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7387989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7389989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/strg[ ]*:[ ]*([^ ]*)/)
7390989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7391989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            my $Str = $1;
739207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}
7393570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $Str=~/\Ac99_(.+)\Z/)
7394570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
7395989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CppKeywords_A{$1}) {
7396989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    $Str=$1;
7397989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7399989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $Str;
7400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7402989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncShortName($)
7406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7407989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7409570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(index($Info, " operator ")!=-1)
7410989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7411570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Info, " conversion ")!=-1)
741262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
741362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Rid = $SymbolInfo{$Version}{$_[0]}{"Return"})
741462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
741562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $RName = $TypeInfo{$Version}{$Rid}{"Name"}) {
741662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator ".$RName;
741762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
741862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
7419989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7420989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            else
7421989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
742262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Info=~/ operator[ ]+([a-zA-Z]+) /)
742362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
742462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $Ind = $Operator_Indication{$1}) {
742562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        return "operator".$Ind;
742662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
742762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    elsif(not $UnknownOperator{$1})
742862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
742962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        printMsg("WARNING", "unknown operator $1");
743062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $UnknownOperator{$1} = 1;
743162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
7432989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7433989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7437989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($Info=~/name[ ]*:[ ]*@(\d+) /) {
7438989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return getTreeStr($1);
7439989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7442989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "";
7443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncReturn($)
7446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7447989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7448989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7449989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7450989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7451989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if($LibInfo{$Version}{"info"}{$1}=~/retn[ ]*:[ ]*@(\d+) /) {
7452989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return $1;
7453989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncOrig($)
7460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7461989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7462989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7463989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/orig[ ]*:[ ]*@(\d+) /) {
7464989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7465989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7467989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return $_[0];
7468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unmangleArray(@)
7471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7472dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($_[0]=~/\A\?/)
7473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC mangling
7474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UndNameCmd = get_CmdPath("undname");
7475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UndNameCmd) {
7476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"undname\"");
7477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        writeFile("$TMP_DIR/unmangle", join("\n", @_));
7479a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return split(/\n/, `$UndNameCmd 0x8386 \"$TMP_DIR/unmangle\"`);
7480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC mangling
7483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CppFiltCmd = get_CmdPath("c++filt");
7484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CppFiltCmd) {
7485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find c++filt in PATH");
7486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
74879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not defined $CPPFILT_SUPPORT_FILE)
74889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
74899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $Info = `$CppFiltCmd -h 2>&1`;
74909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $CPPFILT_SUPPORT_FILE = $Info=~/\@<file>/;
74919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
7492570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $NoStrip = ($OSgroup=~/macos|windows/)?"-n":"";
74939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CPPFILT_SUPPORT_FILE)
74949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # new versions of c++filt can take a file
74959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_CPPFILT_FILE_SIZE)
74969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # c++filt <= 2.22 may crash on large files (larger than 8mb)
74979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # this is fixed in the oncoming version of Binutils
74989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
74999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
75009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
75019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            else
75029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
75039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                writeFile("$TMP_DIR/unmangle", join("\n", @_));
75049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip \@\"$TMP_DIR/unmangle\"`;
75059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
75069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
75079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_CPPFILT_FILE_SIZE constant");
75089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
75099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
7513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old-style unmangling
75149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($#_>$MAX_COMMAND_LINE_ARGUMENTS)
75159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
7516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @Half = splice(@_, 0, ($#_+1)/2);
7517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return (unmangleArray(@Half), unmangleArray(@_))
7518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
7520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Strings = join(" ", @_);
75229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Res = `$CppFiltCmd $NoStrip $Strings`;
75239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($?==139)
75249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # segmentation fault
75259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    printMsg("ERROR", "internal error - c++filt crashed, try to reduce MAX_COMMAND_LINE_ARGUMENTS constant");
75269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
75279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return split(/\n/, $Res);
7528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SignatureNoInfo($$)
7534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
753562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
753662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_SignatureNoInfo"}{$LibVersion}{$Symbol}) {
753762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_SignatureNoInfo"}{$LibVersion}{$Symbol};
7538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
753962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
7540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $tr_name{$MnglName}?$tr_name{$MnglName}:$MnglName;
754162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # C++
75431477d2c1a4df8ea5c19b19604da6d4c5b7016d72Andrey Ponomarenko        # some standard typedefs
7544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature=~s/\Qstd::basic_string<char, std::char_traits<char>, std::allocator<char> >\E/std::string/g;
7545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature=~s/\Qstd::map<std::string, std::string, std::less<std::string >, std::allocator<std::pair<std::string const, std::string > > >\E/std::map<std::string, std::string>/g;
7546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
754782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if(not $CheckObjectsOnly or $OSgroup=~/linux|bsd|beos/i)
7548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # ELF format marks data as OBJECT
754962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($GlobalDataObject{$LibVersion}{$Symbol}) {
7550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Signature .= " [data]";
7551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
755262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($Symbol!~/\A(_Z|\?)/) {
7553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Signature .= " (...)";
7554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
755662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
75581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ShortName = substr($Signature, 0, find_center($Signature, "("));
7559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E/$ShortName $ChargeLevel/g;
7560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
7562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
756462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"get_SignatureNoInfo"}{$LibVersion}{$Symbol} = $Signature);
7565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_ChargeLevel($$)
7568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
756962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
757062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if($Symbol!~/\A(_Z|\?)/);
757162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
757262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
7573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
757462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"})
7575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7576f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/C1[EI]/) {
7577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7579f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/C2[EI]/) {
7580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
758362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"})
7584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7585f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Symbol=~/D1[EI]/) {
7586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge]";
7587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7588f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D2[EI]/) {
7589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[not-in-charge]";
7590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7591f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            elsif($Symbol=~/D0[EI]/) {
7592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return "[in-charge-deleting]";
7593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7598f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Symbol=~/C1[EI]/) {
7599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7601f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/C2[EI]/) {
7602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7604f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D1[EI]/) {
7605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge]";
7606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7607f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D2[EI]/) {
7608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[not-in-charge]";
7609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7610f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($Symbol=~/D0[EI]/) {
7611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "[in-charge-deleting]";
7612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
76170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub get_Signature_M($$)
76180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
76190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
76200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Signature_M = $tr_name{$Symbol};
76210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(my $RTid = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
76220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # add return type name
762362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Signature_M = $TypeInfo{$LibVersion}{$RTid}{"Name"}." ".$Signature_M;
76240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
76250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Signature_M;
76260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
76270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
7628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Signature($$)
7629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
763062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
763162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"get_Signature"}{$LibVersion}{$Symbol}) {
763262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_Signature"}{$LibVersion}{$Symbol};
7633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
763462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
763562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(isPrivateData($MnglName) or not $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
76360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # non-public global data
763762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return get_SignatureNoInfo($Symbol, $LibVersion);
7638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
76398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Signature, @Param_Types_FromUnmangledName) = ();
764062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
764162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
7642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7643fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
7644fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
7645fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::";
7646fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}) {
7647fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Signature .= "~";
7648fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
7649fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
765162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"}) {
7652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $NameSpace."::".$ShortName;
7653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7655fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Signature .= $ShortName;
7656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
765707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my ($Short, $Params) = split_Signature($tr_name{$MnglName});
765807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        @Param_Types_FromUnmangledName = separate_Params($Params, 0, 1);
7659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
7661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
7662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Signature .= $MnglName;
7663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @ParamArray = ();
766562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Pos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
7666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Pos eq "");
766862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"};
7669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ParamTypeId);
767062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ParamTypeName = $TypeInfo{$LibVersion}{$ParamTypeId}{"Name"};
7671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ParamTypeName) {
7672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamTypeName = $Param_Types_FromUnmangledName[$Pos];
7673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
7675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
76768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
76778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $ParamTypeName=~s/\b\Q$Typedef\E\b/$Base/g;
76788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
7679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7680177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ParamName = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"name"})
7681177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
7682f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($ParamName eq "this"
7683f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            and $Symbol=~/\A(_Z|\?)/)
7684177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # do NOT show first hidded "this"-parameter
7685f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                next;
7686177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
7687f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            push(@ParamArray, create_member_decl($ParamTypeName, $ParamName));
7688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ParamArray, $ParamTypeName);
7691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
769362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"}
769462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or $GlobalDataObject{$LibVersion}{$Symbol}) {
76958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " [data]";
7696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
769962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $ChargeLevel = get_ChargeLevel($Symbol, $LibVersion))
7700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add [in-charge]
77018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " ".$ChargeLevel;
7702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
77038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= " (".join(", ", @ParamArray).")";
770462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Const"}
770562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(V|)K/) {
77068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " const";
7707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
770862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Volatile"}
770962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or $Symbol=~/\A_ZN(K|)V/) {
77108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " volatile";
7711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
771262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Static"}
771362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $Symbol=~/\A(_Z|\?)/)
771474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # for static methods
77158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Signature .= " [static]";
7716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $ShowRetVal
771962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and my $ReturnTId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"}) {
77208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= ":".$TypeInfo{$LibVersion}{$ReturnTId}{"Name"};
7721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolVersion) {
77238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= $VersionSpec.$SymbolVersion;
7724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
77258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"get_Signature"}{$LibVersion}{$Symbol} = $Signature);
7726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_member_decl($$)
7729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TName, $Member) = @_;
7731989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($TName=~/\([\*]+\)/)
7732989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TName=~s/\(([\*]+)\)/\($1$Member\)/;
7734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName;
7735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
7737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @ArraySizes = ();
7739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while($TName=~s/(\[[^\[\]]*\])\Z//) {
7740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@ArraySizes, $1);
7741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $TName." ".$Member.join("", @ArraySizes);
7743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncType($)
7747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7748989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7749989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7750989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+) /)
7751989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
7752989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(my $Type = $LibInfo{$Version}{"info_type"}{$1})
7753989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
7754989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Type eq "method_type") {
7755989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Method";
7756989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7757989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                elsif($Type eq "function_type") {
7758989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Function";
7759989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7760989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                else {
7761989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    return "Other";
7762989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
7763989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
7764989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7766f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return "";
7767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getFuncTypeId($)
7770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7771989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($_[0] and my $Info = $LibInfo{$Version}{"info"}{$_[0]})
7772989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    {
7773989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($Info=~/type[ ]*:[ ]*@(\d+)( |\Z)/) {
7774989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            return $1;
7775989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
7776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7777989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAnon($)
7781989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # "._N" or "$_N" in older GCC versions
7782989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($_[0] and $_[0]=~/(\.|\$)\_\d+|anon\-/);
7783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
77859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub formatName($$)
778662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{ # type name correction
77879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"formatName"}{$_[1]}{$_[0]}) {
77889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"formatName"}{$_[1]}{$_[0]};
778962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
779062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7791f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $_[0];
779262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
77939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] ne "S")
77949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
77959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/\A[ ]+//g;
77969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]+\Z//g;
77979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $N=~s/[ ]{2,}/ /g;
77989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
77999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
78009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $N=~s/[ ]*(\W)[ ]*/$1/g; # std::basic_string<char> const
780162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7802f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\bvolatile const\b/const volatile/g;
780362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7804f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(long long|short|long) unsigned\b/unsigned $1/g;
7805f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/\b(short|long) int\b/$1/g;
780662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7807f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $N=~s/([\)\]])(const|volatile)\b/$1 $2/g;
780862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
7809f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while($N=~s/>>/> >/g) {};
781062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
78119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($_[1] eq "S")
78129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
78139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($N, "operator")!=-1) {
78149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N=~s/\b(operator[ ]*)> >/$1>>/;
78159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
78169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
781762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
78189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"formatName"}{$_[1]}{$_[0]} = $N);
7819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_HeaderDeps($$)
7822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($AbsPath, $LibVersion) = @_;
7824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $AbsPath or not $LibVersion);
7825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}) {
7826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %IncDir = ();
7829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_recursive_includes($AbsPath, $LibVersion);
7830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderPath (keys(%{$RecursiveIncludes{$LibVersion}{$AbsPath}}))
7831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $HeaderPath);
7833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($MAIN_CPP_DIR and $HeaderPath=~/\A\Q$MAIN_CPP_DIR\E([\/\\]|\Z)/);
7834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Dir = get_dirname($HeaderPath);
7835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prefix (keys(%{$Header_Include_Prefix{$LibVersion}{$AbsPath}{$HeaderPath}}))
7836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dep = $Dir;
7838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Prefix)
7839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
7840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($OSgroup eq "windows")
7841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # case insensitive seach on windows
7842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//ig) {
7843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
7844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($OSgroup eq "macos")
7847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # seach in frameworks
7848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
7850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($HeaderPath=~/(.+\.framework)\/Headers\/([^\/]+)/)
7851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# frameworks
7852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my ($HFramework, $HName) = ($1, $2);
7853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $Dep = $HFramework;
7854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
7856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {# mismatch
7857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
7858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
7859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
7860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(not $Dep=~s/[\/\\]+\Q$Prefix\E\Z//g)
7862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Linux, FreeBSD
7863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
7864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
7865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $Dep)
7867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nothing to include
7868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(is_default_include_dir($Dep))
7871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # included by the compiler
7872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(get_depth($Dep)==1)
7875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # too short
7876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isLibcDir($Dep))
7879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # do NOT include /usr/include/{sys,bits}
7880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
7881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
7882570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $IncDir{$Dep} = 1;
7883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath} = sortIncPaths([keys(%IncDir)], $LibVersion);
7886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @{$Cache{"get_HeaderDeps"}{$LibVersion}{$AbsPath}};
7887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub sortIncPaths($$)
7890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $LibVersion) = @_;
7892989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(not $ArrRef or $#{$ArrRef}<0) {
7893989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $ArrRef;
7894989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {$b cmp $a} @{$ArrRef};
7896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @{$ArrRef} = sort {get_depth($a)<=>get_depth($b)} @{$ArrRef};
7897989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    @{$ArrRef} = sort {sortDeps($b, $a, $LibVersion)} @{$ArrRef};
7898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ArrRef;
7899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7901989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub sortDeps($$$)
7902989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{
7903989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Header_Dependency{$_[2]}{$_[0]}
7904989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and not $Header_Dependency{$_[2]}{$_[1]}) {
7905989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return 1;
7906989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7907989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    elsif(not $Header_Dependency{$_[2]}{$_[0]}
7908989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    and $Header_Dependency{$_[2]}{$_[1]}) {
7909989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return -1;
7910989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
7911989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return 0;
7912989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko}
7913989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
791474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub join_P($$)
791574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
791674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $S = "/";
791774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($OSgroup eq "windows") {
791874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $S = "\\";
791974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
792074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return join($S, @_);
7921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_namespace_additions($)
7924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $NameSpaces = $_[0];
7926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Additions, $AddNameSpaceId) = ("", 1);
7927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $NS (sort {$a=~/_/ <=> $b=~/_/} sort {lc($a) cmp lc($b)} keys(%{$NameSpaces}))
7928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
7929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($SkipNameSpaces{$Version}{$NS});
7930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $NS or $NameSpaces->{$NS}==-1);
7931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/(\A|::)iterator(::|\Z)/i);
7932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS=~/\A__/i);
7933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(($NS=~/\Astd::/ or $NS=~/\A(std|tr1|rel_ops|fcntl)\Z/) and not $STDCXX_TESTING);
79341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $NestedNameSpaces{$Version}{$NS} = 1; # for future use in reports
7935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($TypeDecl_Prefix, $TypeDecl_Suffix) = ();
7936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @NS_Parts = split(/::/, $NS);
7937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($#NS_Parts==-1);
7938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($NS_Parts[0]=~/\A(random|or)\Z/);
7939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $NS_Part (@NS_Parts)
7940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
7941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Prefix .= "namespace $NS_Part\{";
7942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TypeDecl_Suffix .= "}";
7943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
794474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TypeDecl = $TypeDecl_Prefix."typedef int tmp_add_type_".$AddNameSpaceId.";".$TypeDecl_Suffix;
7945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FuncDecl = "$NS\:\:tmp_add_type_$AddNameSpaceId tmp_add_func_$AddNameSpaceId(){return 0;};";
7946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Additions.="  $TypeDecl\n  $FuncDecl\n";
7947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $AddNameSpaceId+=1;
7948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Additions;
7950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub path_format($$)
795374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
7954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Fmt) = @_;
795574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $Path=~s/[\/\\]+\.?\Z//g;
79561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Fmt eq "windows")
79571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
7958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\//\\/g;
7959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=lc($Path);
7960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
796174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else
796274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # forward slash to pass into MinGW GCC
7963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path=~s/\\/\//g;
7964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
7966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub inc_opt($$)
7969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Style) = @_;
7971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Style eq "GCC")
79721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC options
7973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
79741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # to MinGW GCC
7975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I\"".path_format($Path, "unix")."\"";
7976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($OSgroup eq "macos"
7978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\.framework\Z/)
7979570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # to Apple's GCC
7980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-F".esc(get_dirname($Path));
7981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
7983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "-I".esc($Path);
7984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
7985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Style eq "CL") {
798762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return "/I \"".$Path."\"";
7988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
7989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
7990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
7991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
7992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub platformSpecs($)
7993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
7994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
7995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = getArch($LibVersion);
7996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "symbian")
7997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # options for GCCE compiler
7998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Symbian_Opts = map {$_=>1} (
7999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__GCCE__",
8000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DUNICODE",
8001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-fexceptions",
8002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SYMBIAN32__",
8003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_INTERWORK__",
8004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_UNICODE",
8005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_50__",
8006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__S60_3X__",
8007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SERIES60_3X__",
8008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EPOC32__",
8009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM__",
8010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__EABI__",
8011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__MARM_ARMV5__",
8012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__SUPPORT_CPP_EXCEPTIONS__",
8013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-march=armv5t",
8014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mapcs",
8015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-mthumb-interwork",
8016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DEKA2",
8017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSYMBIAN_ENABLE_SPLIT_HEADERS"
8018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        );
8019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%Symbian_Opts));
8020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows"
8022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i)
8023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add options to MinGW compiler
8024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to simulate the MSVC compiler
8025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %MinGW_Opts = map {$_=>1} (
8026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_WIN32",
8027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_STDCALL_SUPPORTED",
8028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int64=\"long long\"",
8029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int32=int",
8030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int16=short",
8031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__int8=char",
8032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__possibly_notnullterminated=\" \"",
8033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullterminated=\" \"",
8034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__nullnullterminated=\" \"",
8035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__w64=\" \"",
8036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr32=\" \"",
8037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__ptr64=\" \"",
8038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=inline",
8039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__inline=inline",
8040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__uuidof(x)=IID()",
8041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__try=",
8042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__except(x)=",
8043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__declspec(x)=__attribute__((x))",
8044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__pragma(x)=",
8045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_inline=inline",
8046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__forceinline=__inline",
8047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__stdcall=__attribute__((__stdcall__))",
8048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__cdecl=__attribute__((__cdecl__))",
8049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__fastcall=__attribute__((__fastcall__))",
8050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__thiscall=__attribute__((__thiscall__))",
8051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_stdcall=__attribute__((__stdcall__))",
8052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_cdecl=__attribute__((__cdecl__))",
8053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_fastcall=__attribute__((__fastcall__))",
8054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_thiscall=__attribute__((__thiscall__))",
8055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSHSTDAPI_(x)=x",
8056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_EXTENSIONS",
8057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSECURITY_WIN32",
8058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_MSC_VER=1500",
8059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D_USE_DECLSPECS_FOR_SAL",
8060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__noop=\" \"",
8061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DDECLSPEC_DEPRECATED=\" \"",
8062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-D__builtin_alignof(x)=__alignof__(x)",
8063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            "-DSORTPP_PASS");
8064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch eq "x86") {
8065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IX86=300"}=1;
8066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "x86_64") {
8068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_AMD64=300"}=1;
8069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Arch eq "ia64") {
8071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGW_Opts{"-D_M_IA64=300"}=1;
8072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return join(" ", keys(%MinGW_Opts));
8074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %C_Structure = map {$_=>1} (
8079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# FIXME: Can't separate union and struct data types before dumping,
8080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# so it sometimes cause compilation errors for unknown reason
8081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# when trying to declare TYPE* tmp_add_class_N
8082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko# This is a list of such structures + list of other C structures
8083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigval",
8084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigevent",
8085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaction",
8086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigvec",
8087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigstack",
8088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeval",
8089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timezone",
8090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rusage",
8091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rlimit",
8092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "wait",
8093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "flock",
8094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat",
8095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat",
8096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat32",
8097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat32",
8098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "stat64",
8099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stat64",
8100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_stati64",
8101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "if_nameindex",
8102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "usb_device",
8103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sigaltstack",
8104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sysinfo",
8105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timeLocale",
8106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tcp_debug",
8107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "rpc_createerr",
810882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Other
8109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "timespec",
8110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "random_data",
8111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "drand48_data",
8112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_marker",
8113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_IO_FILE",
8114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "lconv",
8115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "sched_param",
8116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "tm",
8117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "itimerspec",
8118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "_pthread_cleanup_buffer",
8119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "fd_set",
812001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    "siginfo",
812182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "mallinfo",
8122570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "timex",
812374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "sigcontext",
812474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    "ucontext",
812582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko # Mac
812682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_timex",
812782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_t",
812882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_category_t",
812982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_class_ro_t",
813082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_protocol_t",
813182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_message_ref_t",
813282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_super_message_ref_t",
813382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_t",
813482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    "_ivar_list_t"
8135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
8136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getCompileCmd($$$)
8138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Opt, $Inc) = @_;
8140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccCall = $GCC_PATH;
8141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Opt) {
8142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opt;
8143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $GccCall .= " -x ";
8145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos") {
8146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "objective-";
8147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8148f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
8149f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($EMERGENCY_MODE_48)
8150f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    { # workaround for GCC 4.8 (C only)
8151f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $GccCall .= "c++";
8152f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
8153f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    elsif(check_gcc($GCC_PATH, "4"))
8154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" header
8155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # to obtain complete dump using GCC 4.0
8156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++-header";
8157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compile as "C++" source
8160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # GCC 3.3 cannot compile headers
8161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= "c++";
8162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Opts = platformSpecs($Version))
8164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {# platform-specific options
8165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Opts;
8166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # allow extra qualifications
8168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # and other nonconformant code
816901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -fpermissive";
817001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $GccCall .= " -w";
8171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($NoStdInc)
8172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc";
8174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " -nostdinc++";
8175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompilerOptions{$Version})
8177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined options
8178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$CompilerOptions{$Version};
8179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8180a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    $GccCall .= " \"$Path\"";
8181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Inc)
8182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # include paths
8183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GccCall .= " ".$Inc;
8184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccCall;
8186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
818801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub detectPreamble($$)
8189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
819001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Content, $LibVersion) = @_;
8191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeaderElems = (
8192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Types
8193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdio.h" => ["FILE", "va_list"],
8194850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "stddef.h" => ["NULL", "ptrdiff_t"],
81959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdint.h" => ["uint8_t", "uint16_t", "uint32_t", "uint64_t",
81969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                       "int8_t", "int16_t", "int32_t", "int64_t"],
8197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "time.h" => ["time_t"],
8198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "sys/types.h" => ["ssize_t", "u_int32_t", "u_short", "u_char",
81999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                          "u_int", "off_t", "u_quad_t", "u_long", "mode_t"],
82009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "unistd.h" => ["gid_t", "uid_t", "socklen_t"],
8201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "stdbool.h" => ["_Bool"],
8202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "rpc/xdr.h" => ["bool_t"],
8203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "in_systm.h" => ["n_long", "n_short"],
8204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Fields
8205bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        "arpa/inet.h" => ["fw_src", "ip_src"],
8206bede837470a7f2717ff60889049b6bbd2f33d224Andrey Ponomarenko        # Functions
82079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        "stdlib.h" => ["free", "malloc", "size_t"],
8208850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        "string.h" => ["memmove", "strcmp"]
8209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
8210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AutoPreamble = ();
8211850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach (keys(%HeaderElems))
8212850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
8213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Elem (@{$HeaderElems{$_}}) {
82149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $AutoPreamble{$Elem} = $_;
8215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
821701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %Types = ();
821801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    while($Content=~s/error\:\s*(field\s*|)\W+(.+?)\W+//)
821901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # error: 'FILE' has not been declared
82209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Types{$2} = 1;
822101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
822201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%Types))
822301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
822401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my %AddHeaders = ();
822501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        foreach my $Type (keys(%Types))
822601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
822701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(my $Header = $AutoPreamble{$Type})
822801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
82299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Path = identifyHeader($Header, $LibVersion))
82309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
82319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(skipHeader($Path, $LibVersion)) {
82329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
82339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
82349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Path = path_format($Path, $OSgroup);
82359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Type"} = $Type;
82369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $AddHeaders{$Path}{"Header"} = $Header;
823701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
823801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
823901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
824001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(keys(%AddHeaders)) {
82419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return \%AddHeaders;
824201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
824301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
82449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return undef;
824501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
824601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
8247f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub checkCTags($)
8248f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko{
8249f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Path = $_[0];
8250f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $Path) {
8251f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8252f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8253570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $CTags = undef;
8254570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8255570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($OSgroup eq "bsd")
8256570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # use ectags on BSD
8257570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ectags");
8258570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CTags) {
8259570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            printMsg("WARNING", "can't find \'ectags\' program");
8260570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8261570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8262f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $CTags) {
8263570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CTags = get_CmdPath("ctags");
8264570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8265570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $CTags)
8266570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8267570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("WARNING", "can't find \'ctags\' program");
8268f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return;
8269f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8270bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
827182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    if($OSgroup ne "linux")
827282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko    { # macos, freebsd, etc.
8273bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Info = `$CTags --version 2>\"$TMP_DIR/null\"`;
8274bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if($Info!~/exuberant/i)
8275bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
8276bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            printMsg("WARNING", "incompatible version of \'ctags\' program");
8277bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            return;
8278bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        }
8279bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    }
8280bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8281f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/ctags.txt";
8282bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    system("$CTags --c-kinds=pxn -f \"$Out\" \"$Path\" 2>\"$TMP_DIR/null\"");
8283f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($Debug) {
82849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        copy($Out, $DEBUG_PATH{$Version}."/ctags.txt");
8285f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8286f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    open(CTAGS, "<", $Out);
8287f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    while(my $Line = <CTAGS>)
8288f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
8289f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        chomp($Line);
8290f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($Name, $Header, $Def, $Type, $Scpe) = split(/\t/, $Line);
82919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $Intrinsic_Keywords{$Name})
82929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # noise
82939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
82949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8295f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Type eq "n")
8296f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
82979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "class:")==0) {
82989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
82999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
83009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "struct:")==0) {
8301f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                next;
8302f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
83039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(index($Scpe, "namespace:")==0)
8304f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
83059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Scpe=~s/\Anamespace://) {
83069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Name = $Scpe."::".$Name;
83079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
83089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
83099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TUnit_NameSpaces{$Version}{$Name} = 1;
83109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
83119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "p")
83129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
83139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
83149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Funcs{$Version}{$Name} = 1;
83159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
83169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
83179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        elsif($Type eq "x")
83189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
83199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $Scpe or index($Scpe, "namespace:")==0) {
83209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $TUnit_Vars{$Version}{$Name} = 1;
8321f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
8322f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8323f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
8324f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    close(CTAGS);
8325f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
8326f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
83278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub preChange($$)
832801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
83298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($HeaderPath, $IncStr) = @_;
83309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
83318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $PreprocessCmd = getCompileCmd($HeaderPath, "-E", $IncStr);
83328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Content = undef;
833307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
8334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows"
8335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and get_dumpmachine($GCC_PATH)=~/mingw/i
8336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $MinGWMode{$Version}!=-1)
8337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify headers to compile by MinGW
83388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
83408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/__asm\s*(\{[^{}]*?\}|[^{};]*)//g)
8343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # __asm { ... }
8344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/\s+(\/ \/.*?)\n/\n/g)
8347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # comments after preprocessing
8348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\W)(0x[a-f]+|\d+)(i|ui)(8|16|32|64)(\W)/$1$2$5/g)
8351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 0xffui8
8352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MinGWMode{$Version}=1;
8353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
83558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($MinGWMode{$Version}) {
8356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("INFO", "Using MinGW compatibility mode");
8357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
83598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
8360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($COMMON_LANGUAGE{$Version} eq "C" or $CheckHeadersOnly)
83618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    and $CppMode{$Version}!=-1 and not $CppCompat and not $CPP_HEADERS)
83621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # rename C++ keywords in C code
8363570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # disable this code by -cpp-compatible option
83648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Content)
8365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # preprocessing
83668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Content = `$PreprocessCmd 2>\"$TMP_DIR/null\"`;
8367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_C = join("|", keys(%CppKeywords_C));
8369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_F = join("|", keys(%CppKeywords_F));
8370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegExp_O = join("|", keys(%CppKeywords_O));
8371bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
8372bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        my $Detected = undef;
8373bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko
83748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        while($Content=~s/(\A|\n[^\#\/\n][^\n]*?|\n)(\*\s*|\s+|\@|\,|\()($RegExp_C|$RegExp_F)(\s*(\,|\)|\;|\-\>|\.|\:\s*\d))/$1$2c99_$3$4/g)
8375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int new, int class, int (*new)(int));
8377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # unsigned private: 8;
8378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # #pragma GCC visibility push(default)
838007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8381bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
8382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\s]|\w\s+)(?<!operator )(delete)(\s*\()/$1c99_$2$3/g)
8384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int delete(...);
8386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int explicit(...);
8387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void operator delete(...)
838907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8390bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
83928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)($RegExp_O)(\s*(\;|\:))/$1c99_$2$3/g)
8393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bool;
8395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # bool X;
8397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # return *this;
8398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # throw;
839907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8400bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\s+)(operator)(\s*(\(\s*\)\s*[^\(\s]|\(\s*[^\)\s]))/$1c99_$2$3/g)
8403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator(...);
8405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator()(...);
840707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8408bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/([^\w\(\,\s]\s*|\s+)(operator)(\s*(\,\s*[^\(\s]|\)))/$1c99_$2$3/g)
8411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator);
8413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int operator, int other);
8414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int operator,(...);
841607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8417bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\*\s*|\w\s+)(bool)(\s*(\,|\)))/$1c99_$2$3/g)
8420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(gboolean *bool);
8422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
8423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # void setTabEnabled(int index, bool);
842407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8425bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3" if(not defined $Detected);
8426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(\w)(\s*[^\w\(\,\s]\s*|\s+)(this|throw)(\s*[\,\)])/$1$2c99_$3$4/g)
8428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # MATCH:
8429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int foo(int* this);
8430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # int bar(int this);
84319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # int baz(int throw);
8432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # DO NOT MATCH:
84339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko          # foo(X, this);
843407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $CppMode{$Version} = 1;
8435bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            $Detected = "$1$2$3$4" if(not defined $Detected);
843607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
84378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Content=~s/(struct |extern )(template) /$1c99_$2 /g)
84388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # MATCH:
84398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # struct template {...};
84408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # extern template foo(...);
84418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CppMode{$Version} = 1;
84428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Detected = "$1$2" if(not defined $Detected);
84438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
844407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
844507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version} == 1)
844607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
8447bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            if($Debug)
8448bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko            {
8449bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                $Detected=~s/\A\s+//g;
8450bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko                printMsg("INFO", "Detected code: \"$Detected\"");
845107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
8452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
84539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
84549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # remove typedef enum NAME NAME;
84558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @FwdTypedefs = $Content=~/typedef\s+enum\s+(\w+)\s+(\w+);/g;
84569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $N = 0;
84579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while($N<=$#FwdTypedefs-1)
84589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
84599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my $S = $FwdTypedefs[$N];
84609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($S eq $FwdTypedefs[$N+1])
84619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
84628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Content=~s/typedef\s+enum\s+\Q$S\E\s+\Q$S\E;//g;
8463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CppMode{$Version} = 1;
8464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
8465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Debug) {
8466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    printMsg("INFO", "Detected code: \"typedef enum $S $S;\"");
8467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
84689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
84699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $N+=2;
84709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
84719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
84728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($CppMode{$Version}==1) {
847307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            printMsg("INFO", "Using C++ compatibility mode");
8474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
84768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
847707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1)
84798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
84808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $IPath = $TMP_DIR."/dump$Version.i";
84818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($IPath, $Content);
84828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $IPath;
84838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return undef;
84868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
84878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub getDump()
84898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
84908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $GCC_PATH) {
84918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        exitStatus("Error", "internal error - GCC path is not set");
84928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
84938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my @Headers = keys(%{$Registered_Headers{$Version}});
84958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    @Headers = sort {int($Registered_Headers{$Version}{$a}{"Pos"})<=>int($Registered_Headers{$Version}{$b}{"Pos"})} @Headers;
84968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $IncludeString = getIncString(getIncPaths(@{$Include_Preamble{$Version}}, @Headers), "GCC");
84988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
84998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TmpHeaderPath = $TMP_DIR."/dump".$Version.".h";
85008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $HeaderPath = $TmpHeaderPath;
85018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # write tmp-header
85038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    open(TMP_HEADER, ">", $TmpHeaderPath) || die ("can't open file \'$TmpHeaderPath\': $!\n");
85048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $AddDefines = $Descriptor{$Version}{"Defines"})
85058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
85068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $AddDefines=~s/\n\s+/\n  /g;
85078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "\n  // add defines\n  ".$AddDefines."\n";
85088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
85098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    print TMP_HEADER "\n  // add includes\n";
85108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@{$Include_Preamble{$Version}}) {
85118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
85128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
85138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $HPath (@Headers)
85148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
85158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not grep {$HPath eq $_} (@{$Include_Preamble{$Version}})) {
85168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            print TMP_HEADER "  #include \"".path_format($HPath, "unix")."\"\n";
85178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
85188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
85198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    close(TMP_HEADER);
85208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
85228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
85238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($IncludeString) {
85248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-string", $IncludeString);
85258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
85268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/recursive-includes", Dumper($RecursiveIncludes{$Version}));
85278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/direct-includes", Dumper($Header_Includes{$Version}));
85288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my @Redirects = keys(%{$Header_ErrorRedirect{$Version}}))
85308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
85318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $REDIR = "";
85328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $P1 (sort @Redirects) {
85338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $REDIR .= $P1.";".$Header_ErrorRedirect{$Version}{$P1}."\n";
85348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
85358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            writeFile($ExtraInfo."/include-redirect", $REDIR);
85368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
85378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
85388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$TargetHeaders{$Version}}))
85408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Target headers
85418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        addTargetHeaders($Version);
8542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8543850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8544850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
85458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %RecursiveIncludes = ();
85468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Include_Prefix = ();
85478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %Header_Includes = ();
85488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean cache
85508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"identifyHeader"});
85518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"detect_header_includes"});
85528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Cache{"selectSystemHeader"});
85538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # preprocessing stage
85558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Pre = callPreprocessor($TmpHeaderPath, $IncludeString, $Version);
85568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    checkPreprocessedUnit($Pre);
85578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtraInfo)
85598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # extra information for other tools
85608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        writeFile($ExtraInfo."/header-paths", join("\n", sort keys(%{$PreprocessedHeaders{$Version}})));
85618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
85628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # clean memory
85648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($Include_Neighbors{$Version});
85658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    delete($PreprocessedHeaders{$Version});
85668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++") {
85688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        checkCTags($Pre);
85698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
85708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
85718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(my $PrePath = preChange($TmpHeaderPath, $IncludeString))
85728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # try to correct the preprocessor output
85738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $HeaderPath = $PrePath;
85748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
8575850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
8576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$Version} eq "C++")
8577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add classes and namespaces to the dump
8578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CHdump = "-fdump-class-hierarchy -c";
857907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($CppMode{$Version}==1
8580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $MinGWMode{$Version}==1) {
8581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHdump .= " -fpreprocessed";
8582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
85838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $ClassHierarchyCmd = getCompileCmd($HeaderPath, $CHdump, $IncludeString);
8584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($TMP_DIR);
858562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($ClassHierarchyCmd." >null 2>&1");
8586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
8587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $ClassDump = (cmd_find($TMP_DIR,"f","*.class",1))[0])
8588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Content = readFile($ClassDump);
8590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $ClassInfo (split(/\n\n/, $Content))
8591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ClassInfo=~/\AClass\s+(.+)\s*/i)
8593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
8594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $CName = $1;
8595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if($CName=~/\A(__|_objc_|_opaque_)/);
8596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TUnit_NameSpaces{$Version}{$CName} = -1;
8597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/\A[\w:]+\Z/)
8598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # classes
8599f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $TUnit_Classes{$Version}{$CName} = 1;
8600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CName=~/(\w[\w:]*)::/)
8602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # namespaces
8603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NS = $1;
8604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not defined $TUnit_NameSpaces{$Version}{$NS}) {
8605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $TUnit_NameSpaces{$Version}{$NS} = 1;
8606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
8607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($ClassInfo=~/\AVtable\s+for\s+(.+)\n((.|\n)+)\Z/i)
8610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # read v-tables (advanced approach)
8611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($CName, $VTable) = ($1, $2);
8612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ClassVTable_Content{$Version}{$CName} = $VTable;
8613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8615a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $NS (keys(%{$AddNameSpaces{$Version}}))
8616a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            { # add user-defined namespaces
8617a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $TUnit_NameSpaces{$Version}{$NS} = 1;
8618a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
8619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Debug)
8620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # debug mode
8621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                mkpath($DEBUG_PATH{$Version});
86221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                copy($ClassDump, $DEBUG_PATH{$Version}."/class-hierarchy-dump.txt");
8623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($ClassDump);
8625f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8626f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
8627f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # add namespaces and classes
8628f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $NS_Add = get_namespace_additions($TUnit_NameSpaces{$Version}))
8629f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # GCC on all supported platforms does not include namespaces to the dump by default
86308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add namespaces\n".$NS_Add);
8631f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8632f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        # some GCC versions don't include class methods to the TU dump by default
8633f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my ($AddClass, $ClassNum) = ("", 0);
8634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $GCC_44 = check_gcc($GCC_PATH, "4.4"); # support for old GCC versions
8635f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        foreach my $CName (sort keys(%{$TUnit_Classes{$Version}}))
8636f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
8637f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($C_Structure{$CName});
8638f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if(not $STDCXX_TESTING and $CName=~/\Astd::/);
8639f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            next if($SkipTypes{$Version}{$CName});
8640570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $Force and $GCC_44
8641570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and $OSgroup eq "linux")
8642570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # optimization for linux with GCC >= 4.4
8643570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko              # disable this code by -force option
8644570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(index($CName, "::")!=-1)
8645570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # should be added by name space
864682b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
864782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
864882b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            }
864982b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            else
865082b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko            {
865182b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                if($CName=~/\A(.+)::[^:]+\Z/
865282b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                and $TUnit_Classes{$Version}{$1})
865382b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                { # classes inside other classes
865482b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                    next;
865582b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko                }
8656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
86579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Funcs{$Version}{$CName})
86589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a function and type
86599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
86609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
86619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $TUnit_Vars{$Version}{$CName})
86629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # the same name for a variable and type
86639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next;
86649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
8665f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $AddClass .= "  $CName* tmp_add_class_".($ClassNum++).";\n";
8666f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
8667f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($AddClass) {
86688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            appendFile($HeaderPath, "\n  // add classes\n".$AddClass);
8669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "Temporary header file \'$TmpHeaderPath\' with the following content will be compiled to create GCC translation unit dump:\n".readFile($TmpHeaderPath)."\n");
8672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create TU dump
8673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TUdump = "-fdump-translation-unit -fkeep-inline-functions -c";
867407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($CppMode{$Version}==1
8675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $MinGWMode{$Version}==1) {
8676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TUdump .= " -fpreprocessed";
8677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
86788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $SyntaxTreeCmd = getCompileCmd($HeaderPath, $TUdump, $IncludeString);
8679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeLog($Version, "The GCC parameters:\n  $SyntaxTreeCmd\n\n");
8680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($TMP_DIR);
8681a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($SyntaxTreeCmd." >\"$TMP_DIR/tu_errors\" 2>&1");
8682570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Errors = "";
8683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($?)
8684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # failed to compile, but the TU dump still can be created
8685570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors = readFile($TMP_DIR."/tu_errors"))
868601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to recompile
868701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko          # FIXME: handle other errors and try to recompile
868807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if($CppMode{$Version}==1
8689570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            and index($Errors, "c99_")!=-1)
869001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable c99 mode and try again
869107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $CppMode{$Version}=-1;
869207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                printMsg("INFO", "Disabling C++ compatibility mode");
869301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
869401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
869501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
8696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
869701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($AutoPreambleMode{$Version}!=-1
86989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            and my $AddHeaders = detectPreamble($Errors, $Version))
869901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # add auto preamble headers and try again
870001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $AutoPreambleMode{$Version}=-1;
87019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my @Headers = sort {$b cmp $a} keys(%{$AddHeaders}); # sys/types.h should be the first
8702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Num (0 .. $#Headers)
8703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
870401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Path = $Headers[$Num];
8705570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Path eq $_} (@{$Include_Preamble{$Version}}))
8706570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
8707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        push_U($Include_Preamble{$Version}, $Path);
8708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        printMsg("INFO", "Add \'".$AddHeaders->{$Path}{"Header"}."\' preamble header for \'".$AddHeaders->{$Path}{"Type"}."\'");
8709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
8710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                resetLogging($Version);
8712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
8713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return getDump();
8714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
871501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($Cpp0xMode{$Version}!=-1
871601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and ($Errors=~/\Q-std=c++0x\E/
871701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or $Errors=~/is not a class or namespace/))
871801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # c++0x: enum class
8719570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(check_gcc($GCC_PATH, "4.6"))
8720570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8721570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Cpp0xMode{$Version}=-1;
8722570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("INFO", "Enabling c++0x mode");
8723570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    resetLogging($Version);
8724570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $TMP_DIR = tempdir(CLEANUP=>1);
8725570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $CompilerOptions{$Version} .= " -std=c++0x";
8726570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    return getDump();
8727570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8728570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else {
8729570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    printMsg("WARNING", "Probably c++0x construction detected");
8730570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8731570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
873201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
873301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            elsif($MinGWMode{$Version}==1)
873401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # disable MinGW mode and try again
873501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $MinGWMode{$Version}=-1;
873601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                resetLogging($Version);
873701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $TMP_DIR = tempdir(CLEANUP=>1);
873801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return getDump();
873901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
874001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, $Errors);
8741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
874201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        else {
874301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            writeLog($Version, "$!: $?\n");
8744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "some errors occurred when compiling headers");
8746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printErrorLog($Version);
8747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMPILE_ERRORS = $ERROR_CODE{"Compile_Error"};
8748570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeLog($Version, "\n"); # new line
8749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chdir($ORIG_DIR);
8751f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    unlink($TmpHeaderPath);
87528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    unlink($HeaderPath);
8753570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8754570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my @TUs = cmd_find($TMP_DIR,"f","*.tu",1)) {
8755570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $TUs[0];
8756570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8757570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    else
8758570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8759570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my $Msg = "can't compile header(s)";
8760570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Errors=~/error trying to exec \W+cc1plus\W+/) {
8761570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Msg .= "\nDid you install G++?";
8762570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8763570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Cannot_Compile", $Msg);
8764570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmd_file($)
8768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $CmdPath = get_CmdPath("file")) {
8772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return `$CmdPath -b \"$Path\"`;
8773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
8775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncString($$)
8778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ArrRef, $Style) = @_;
8780989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return "" if(not $ArrRef or $#{$ArrRef}<0);
8781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $String = "";
8782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@{$ArrRef}) {
8783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $String .= " ".inc_opt($_, $Style);
8784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $String;
8786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getIncPaths(@)
8789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @HeaderPaths = @_;
8791570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my @IncPaths = @{$Add_Include_Paths{$Version}};
8792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($INC_PATH_AUTODETECT{$Version})
8793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # auto-detecting dependencies
8794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Includes = ();
8795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $HPath (@HeaderPaths)
8796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Dir (get_HeaderDeps($HPath, $Version))
8798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
8799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip_Include_Paths{$Version}{$Dir}) {
8800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
8801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
8802a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if($SystemRoot)
8803a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
8804a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    if($Skip_Include_Paths{$Version}{$SystemRoot.$Dir}) {
8805a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                        next;
8806a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
8807a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
8808570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Includes{$Dir} = 1;
8809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Dir (@{sortIncPaths([keys(%Includes)], $Version)}) {
8812570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@IncPaths, $Dir);
8813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined paths
8817570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @IncPaths = @{$Include_Paths{$Version}};
8818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \@IncPaths;
8820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8822570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub push_U($@)
8823570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{ # push unique
8824570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $Array = shift @_)
8825570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
8826570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(@_)
8827570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
8828570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Exist = map {$_=>1} @{$Array};
8829570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Elem (@_)
8830570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
8831570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not defined $Exist{$Elem})
8832570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
8833570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push(@{$Array}, $Elem);
8834570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Exist{$Elem} = 1;
8835570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
8836570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
8837570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
8838570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
8839570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
8840570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
8841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub callPreprocessor($$$)
8842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Inc, $LibVersion) = @_;
8844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
8845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $IncludeString=$Inc;
8846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Inc) {
8847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IncludeString = getIncString(getIncPaths($Path), "GCC");
8848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = getCompileCmd($Path, "-dD -E", $IncludeString);
8850f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $Out = $TMP_DIR."/preprocessed.h";
8851a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    system($Cmd." >\"$Out\" 2>\"$TMP_DIR/null\"");
8852dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $Out;
8853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
88554b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkosub cmd_find($;$$$$)
8856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # native "find" is much faster than File::Find (~6x)
8857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # also the File::Find doesn't support --maxdepth N option
8858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # so using the cross-platform wrapper for the native one
8859570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($Path, $Type, $Name, $MaxDepth, $UseRegex) = @_;
8860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -e $Path);
8861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
8862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DirCmd = get_CmdPath("dir");
8864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DirCmd) {
8865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dir\" command");
8866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
8869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $DirCmd." \"$Path\" /B /O";
8870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth!=1) {
8871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /S";
8872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " /AD";
8875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
887674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        elsif($Type eq "f") {
887774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Cmd .= " /A-D";
887874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
8879570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, `$Cmd 2>\"$TMP_DIR/null\"`);
8880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Name)
88818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
88828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $UseRegex)
88838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # FIXME: how to search file names in MS shell?
88848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko              # wildcard to regexp
8885570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $Name=~s/\*/.*/g;
88868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Name='\A'.$Name.'\Z';
8887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
88888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/i } @Files;
8889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @AbsPaths = ();
8891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $File (@Files)
8892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
8893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not is_abs($File)) {
889474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $File = join_P($Path, $File);
8895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type eq "f" and not -f $File)
8897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # skip dirs
8898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
8899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, path_format($File, $OSgroup));
8901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "d") {
8903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@AbsPaths, $Path);
8904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return @AbsPaths;
8906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
8908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
8909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FindCmd = get_CmdPath("find");
8910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $FindCmd) {
8911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find a \"find\" command");
8912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = get_abs_path($Path);
8914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-d $Path and -l $Path
8915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path!~/\/\Z/)
8916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # for directories that are symlinks
8917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path.="/";
8918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Cmd = $FindCmd." \"$Path\"";
8920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MaxDepth) {
8921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -maxdepth $MaxDepth";
8922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type) {
8924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Cmd .= " -type $Type";
8925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8926570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and not $UseRegex)
8927570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # wildcards
8928570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cmd .= " -name \"$Name\"";
8929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
89309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Res = `$Cmd 2>\"$TMP_DIR/null\"`;
89318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($? and $!) {
89329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            printMsg("ERROR", "problem with \'find\' utility ($?): $!");
89339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
8934570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Files = split(/\n/, $Res);
8935570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($Name and $UseRegex)
8936570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # regex
89378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            @Files = grep { /$Name/ } @Files;
8938570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
89394b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return @Files;
8940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
8942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
8943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub unpackDump($)
8944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
8945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
8946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -e $Path);
8947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = get_abs_path($Path);
8948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Path = path_format($Path, $OSgroup);
8949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $FileName) = separate_path($Path);
8950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UnpackDir = $TMP_DIR."/unpack";
8951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    rmtree($UnpackDir);
8952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    mkpath($UnpackDir);
8953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($FileName=~s/\Q.zip\E\Z//g)
8954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
8955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $UnzipCmd = get_CmdPath("unzip");
8956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $UnzipCmd) {
8957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"unzip\" command");
8958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($UnpackDir);
896074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        system("$UnzipCmd \"$Path\" >\"$TMP_DIR/null\"");
8961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?) {
896274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
8964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
896574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Contents = cmd_find($UnpackDir, "f");
8966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not @Contents) {
8967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't extract \'$Path\'");
8968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
896974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return $Contents[0];
8970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
8971fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    elsif($FileName=~s/\Q.tar.gz\E(\.\w+|)\Z//g)
8972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
8973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OSgroup eq "windows")
8974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -xvzf option is not implemented in tar.exe (2003)
8975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # use "gzip.exe -k -d -f" + "tar.exe -xvf" instead
8976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
8977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
8978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
8979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
8981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $GzipCmd) {
8982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\" command");
8983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
8985a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system("$GzipCmd -k -d -f \"$Path\""); # keep input files (-k)
8986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
8987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
898974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvf \"$Dir\\$FileName.tar\" >\"$TMP_DIR/null\"");
8990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
899174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
8992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
8993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
8994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Dir."/".$FileName.".tar");
899574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
8996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
8997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
8998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
899974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
9000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
900274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # Unix, Mac
9003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
9004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $TarCmd) {
9005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\" command");
9006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($UnpackDir);
900874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            system("$TarCmd -xvzf \"$Path\" >\"$TMP_DIR/null\"");
9009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($?) {
901074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\' ($?): $!");
9011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            chdir($ORIG_DIR);
901374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my @Contents = cmd_find($UnpackDir, "f");
9014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not @Contents) {
9015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "can't extract \'$Path\'");
9016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
901774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return $Contents[0];
9018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createArchive($$)
9023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $To) = @_;
90255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $To) {
90265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $To = ".";
90275c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
9028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Path or not -e $Path
9029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -d $To) {
9030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
9031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($From, $Name) = separate_path($Path);
9033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "windows")
9034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.zip
9035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ZipCmd = get_CmdPath("zip");
9036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ZipCmd) {
9037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"zip\"");
9038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = $To."/".$Name.".zip";
9040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
9041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($To);
9042a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        system("$ZipCmd -j \"$Name.zip\" \"$Path\" >\"$TMP_DIR/null\"");
9043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
9044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "zip")
9045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
9046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
9047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
9049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
9050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Pkg;
9051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
9053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # *.tar.gz
9054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TarCmd = get_CmdPath("tar");
9055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $TarCmd) {
9056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"tar\"");
9057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $GzipCmd = get_CmdPath("gzip");
9059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GzipCmd) {
9060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"gzip\"");
9061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pkg = abs_path($To)."/".$Name.".tar.gz";
9063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Pkg);
9064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($From);
9065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system($TarCmd, "-czf", $Pkg, $Name);
9066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($?)
9067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # cannot allocate memory (or other problems with "tar")
9068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($Path);
9069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't pack the ABI dump: ".$!);
9070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        chdir($ORIG_DIR);
9072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($Path);
9073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $To."/".$Name.".tar.gz";
9074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header_file($)
9078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.($HEADER_EXT)\Z/i) {
9080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $_[0];
9081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_not_header($)
9086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~/\.\w+\Z/
9088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $_[0]!~/\.($HEADER_EXT)\Z/i) {
9089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
9090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_header($$$)
9095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Header, $UserDefined, $LibVersion) = @_;
9097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(-d $Header);
9098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Header) {
9099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Header = get_abs_path($Header);
9100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
9102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(is_abs($Header))
9104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # incorrect absolute path
9105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
9106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
910762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $HPath = identifyHeader($Header, $LibVersion)) {
9108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Header = $HPath;
9109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
9111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # can't find header
9112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
9113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Header=~/\.\w+\Z/)
9116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # have an extension
9117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return is_header_file($Header);
9118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
9120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserDefined==2)
9122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified on the command line
9123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(cmd_file($Header)!~/HTML|XML/i) {
9124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
9125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($UserDefined)
9128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # specified in the XML-descriptor
9129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # header file without an extension
9130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $Header;
9131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
9133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9134570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Header, "/include/")!=-1
9135850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or cmd_file($Header)=~/C[\+]*\s+program/i)
9136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # !~/HTML|XML|shared|dynamic/i
9137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Header;
9138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
9142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
91441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addTargetHeaders($)
9145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
9147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $RegHeader (keys(%{$Registered_Headers{$LibVersion}}))
9148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RegDir = get_dirname($RegHeader);
915046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko        $TargetHeaders{$LibVersion}{get_filename($RegHeader)} = 1;
91519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
91529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $INC_PATH_AUTODETECT{$LibVersion}) {
91539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            detect_recursive_includes($RegHeader, $LibVersion);
91549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
91559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
9156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $RecInc (keys(%{$RecursiveIncludes{$LibVersion}{$RegHeader}}))
9157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Dir = get_dirname($RecInc);
9159fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9160177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(familiarDirs($RegDir, $Dir)
9161850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or $RecursiveIncludes{$LibVersion}{$RegHeader}{$RecInc}!=1)
9162850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # in the same directory or included by #include "..."
916346bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                $TargetHeaders{$LibVersion}{get_filename($RecInc)} = 1;
9164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9169fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub familiarDirs($$)
9170fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
9171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($D1, $D2) = @_;
9172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($D1 eq $D2) {
9173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
9174fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9175177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9176177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U1 = index($D1, "/usr/");
9177177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $U2 = index($D2, "/usr/");
9178177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9179177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U1==0 and $U2!=0) {
9180177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9181177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9182177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9183177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($U2==0 and $U1!=0) {
9184177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 0;
9185177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9186177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9187177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(index($D2, $D1."/")==0) {
9188177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return 1;
9189177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9190177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9191177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /usr/include/DIR
9192177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # /home/user/DIR
9193177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9194177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my $DL = get_depth($D1);
9195177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9196177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs1 = ($D1);
9197177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while($DL - get_depth($D1)<=2
9198177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and get_depth($D1)>=4
9199177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D1=~s/[\/\\]+[^\/\\]*?\Z//) {
9200177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs1, $D1);
9201177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9202177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9203177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my @Dirs2 = ($D2);
9204177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    while(get_depth($D2)>=4
9205177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $D2=~s/[\/\\]+[^\/\\]*?\Z//) {
9206177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        push(@Dirs2, $D2);
9207177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9208177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9209177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $P1 (@Dirs1)
9210fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
9211177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $P2 (@Dirs2)
9212177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9213177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9214177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($P1 eq $P2) {
9215177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                return 1;
9216177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9217fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
9219fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
9220fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
9221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readHeaders($)
9223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Version = $_[0];
9225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "checking header(s) ".$Descriptor{$Version}{"Version"}." ...");
9226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DumpPath = getDump();
9227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
9228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug mode
9229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
92301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        copy($DumpPath, $DEBUG_PATH{$Version}."/translation-unit-dump.txt");
9231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    getInfo($DumpPath);
9233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub prepareTypes($)
9236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
923862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.0"))
9239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # type names have been corrected in ACC 1.22 (dump 2.0 format)
924162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
9242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
924362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
924462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TName=~/\A(\w+)::(\w+)/) {
924562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my ($P1, $P2) = ($1, $2);
924662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($P1 eq $P2) {
924762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A$P1:\:$P1(\W)/$P1$1/;
924862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
924962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else {
925062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TName=~s/\A(\w+:\:)$P2:\:$P2(\W)/$1$P2$2/;
9251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
925362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Name"} = $TName;
9254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
925662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.5"))
9257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V < 2.5: array size == "number of elements"
9259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # V >= 2.5: array size in bytes
926062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9262f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %Type = get_PureType($TypeId, $TypeInfo{$LibVersion});
926362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Type{"Type"} eq "Array")
9264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
926501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(my $Size = $Type{"Size"})
926662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[N]
9267f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %Base = get_OneStep_BaseType($Type{"Tid"}, $TypeInfo{$LibVersion});
926801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $Size *= $Base{"Size"};
926901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = "$Size";
927062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
927162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
927262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # array[] is a pointer
927362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $WORD_SIZE{$LibVersion};
9274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V2 = ($LibVersion==1)?2:1;
927962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.7"))
9280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
9281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # size of "method ptr" corrected in 2.7
928262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9284f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
928562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($PureType{"Type"} eq "MethodPtr")
9286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
928762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type = get_Type($TypeId, $LibVersion);
928862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TypeId_2 = getTypeIdByName($PureType{"Name"}, $V2);
928962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my %Type2 = get_Type($TypeId_2, $V2);
929062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Type{"Size"} ne $Type2{"Size"}) {
929162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Size"} = $Type2{"Size"};
9292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
92981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub prepareSymbols($)
9299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
93011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
93021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
93031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # check if input is valid
93041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $ExtendedCheck and not $CheckObjectsOnly)
93051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
93061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CheckHeadersOnly) {
93071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty (".$Descriptor{$LibVersion}{"Version"}.")");
93081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
93091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            else {
93101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection (".$Descriptor{$LibVersion}{"Version"}.")");
93111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
93121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
93131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
93141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Remangle = 0;
931662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.10")
931762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.10"))
9318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
9319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Remangle = 1;
9320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly)
9322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different languages
9323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UserLang)
9324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --lang=LANG for both versions
9325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(($UsedDump{1}{"V"} and $UserLang ne $UsedDump{1}{"L"})
9326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or ($UsedDump{2}{"V"} and $UserLang ne $UsedDump{2}{"L"}))
9327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($UserLang eq "C++")
9329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remangle symbols
9330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = 1;
9331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($UserLang eq "C")
9333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # remove mangling
9334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Remangle = -1;
9335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
933962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
93401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (sort {int($b)<=>int($a)} keys(%{$SymbolInfo{$LibVersion}}))
9341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # reverse order: D0, D1, D2, D0 (artificial, GCC < 4.5), C1, C2
934262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.13"))
93430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
93440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
93450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
93460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                foreach my $P (keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}}))
93470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
93480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $TypeId = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"type"};
93490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    my $DVal = $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"};
935062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
93510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $DVal and $DVal ne "")
93520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
93530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($TName eq "char") {
93540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = chr($DVal);
93550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
93560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif($TName eq "bool") {
93570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$P}{"default"} = $DVal?"true":"false";
93580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
93590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
93600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
93610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
93620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
93631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SymbolInfo{$LibVersion}{$InfoId}{"Destructor"})
9364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
93651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
93661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})
9367082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko            and $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
9368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old GCC < 4.5: skip artificial ~dtor(int __in_chrg)
9369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # + support for old ABI dumps
9370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
9371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
93731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9374850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
93751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassID = $SymbolInfo{$LibVersion}{$InfoId}{"Class"};
9376850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $Return = $SymbolInfo{$LibVersion}{$InfoId}{"Return"};
9377989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
93781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $SRemangle = 0;
937962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.12")
938062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.12"))
93811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # support for old ABI dumps
9382850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($ShortName eq "operator>>")
9383850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9384850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
9385850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of operator>>
9386850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9387850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
93881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9389850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
9390850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9391850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
9392850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                and isConstType($Return, $LibVersion) and $MnglName!~/L\d+$ShortName/)
9393850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # corrected mangling of const global data
9394850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # some global data is not mangled in the TU dump: qt_sine_table (Qt 4.8)
9395850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and incorrectly mangled by old ACC versions
9396850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $SRemangle = 1;
9397850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
93981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
93991693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
94005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $CheckHeadersOnly)
94015c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # support for old ABI dumps
94025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            if(not checkDump(1, "2.17")
94035c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            or not checkDump(2, "2.17"))
94045c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            {
94055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                if($SymbolInfo{$LibVersion}{$InfoId}{"Data"})
94065c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                {
94075c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    if(not $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
94085c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    {
94095c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        if(link_symbol($ShortName, $LibVersion, "-Deps"))
94105c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        {
94115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $MnglName = $ShortName;
94125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
94135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                        }
94145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    }
94155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                }
94165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            }
94175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
94181693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Remangle==1 or $SRemangle==1)
9419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old ABI dumps: some symbols are not mangled in old dumps
9420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # mangle both sets of symbols (old and new)
9421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # NOTE: remangling all symbols by the same mangler
9422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(V|)K/)
9423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Const" attribute
94251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Const"} = 1;
9426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/\A_ZN(K|)V/)
9428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # mangling may be incorrect on old ABI dumps
9429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # because of absent "Volatile" attribute
94301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Volatile"} = 1;
9431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
94321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(($ClassID and $MnglName!~/\A(_Z|\?)/)
94331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and $CheckHeadersOnly)
94341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            or (not $ClassID and not link_symbol($MnglName, $LibVersion, "-Deps")))
94351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # support for old ABI dumps, GCC >= 4.0
94361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko              # remangling all manually mangled symbols
94371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($MnglName = mangle_symbol($InfoId, $LibVersion, "GCC"))
9438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
94391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $MnglName;
9440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MangledNames{$LibVersion}{$MnglName} = 1;
9441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Remangle==-1)
9445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # remove mangling
9446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $MnglName = "";
94471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = "";
9448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $MnglName) {
9450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$MnglName}{"MnglName"})
9453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # NOTE: global data may enter here twice
94541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$MnglName}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
94551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
9456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
945762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump($LibVersion, "2.6"))
9458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps
9459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # add "Volatile" attribute
9460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($MnglName=~/_Z(K|)V/) {
9461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompleteSignature{$LibVersion}{$MnglName}{"Volatile"}=1;
9462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # symbol and its symlink have same signatures
9465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymVer{$LibVersion}{$MnglName}) {
94661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$MnglName}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9468850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Alias = $CompleteSignature{$LibVersion}{$MnglName}{"Alias"})
9470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
9471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Alias}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SymVer{$LibVersion}{$Alias}) {
9473fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$CompleteSignature{$LibVersion}{$SymVer{$LibVersion}{$Alias}}} = %{$SymbolInfo{$LibVersion}{$InfoId}};
9474fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
9475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
9476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
9477850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        # clean memory
94781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId});
9479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMMON_LANGUAGE{$LibVersion} eq "C++" or $OSgroup eq "windows") {
9481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        translateSymbols(keys(%{$CompleteSignature{$LibVersion}}), $LibVersion);
9482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
9484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
9485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        addExtension($LibVersion);
9486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9487850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9488850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
9489850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    delete($SymbolInfo{$LibVersion});
9490850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9491850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
9492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect allocable classes with public exported constructors
9493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or classes with auto-generated or inline-only constructors
94949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and other temp info
9495850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
9496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
949762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
9498850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Constructor"}
9499850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"})
9500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Class() { ... } will not be exported
9501850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9503850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly or link_symbol($Symbol, $LibVersion, "-Deps")) {
9504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AllocableClass{$LibVersion}{$ClassName} = 1;
9505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9508850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(not $CompleteSignature{$LibVersion}{$Symbol}{"Private"})
9509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all imported class methods
9510850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Binary"))
9511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9512850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if($CheckHeadersOnly)
9513850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
9514850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if(not $CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
9515850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        or $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
9516850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        { # all symbols except non-virtual inline
9517850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9518850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        }
9519850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9520850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    else {
9521850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ClassMethods{"Binary"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
952462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(symbolFilter($Symbol, $LibVersion, "Affected", "Source")) {
9525850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $ClassMethods{"Source"}{$LibVersion}{$ClassName}{$Symbol} = 1;
9526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
95281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $ClassNames{$LibVersion}{$ClassName} = 1;
9529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9530850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(my $RetId = $CompleteSignature{$LibVersion}{$Symbol}{"Return"})
9531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
953262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Base = get_BaseType($RetId, $LibVersion);
9533850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $Base{"Type"}
9534850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            and $Base{"Type"}=~/Struct|Class/)
9535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
953662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Name = $TypeInfo{$LibVersion}{$Base{"Tid"}}{"Name"};
9537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Name=~/<([^<>\s]+)>/)
9538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
9539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $Tid = getTypeIdByName($1, $LibVersion)) {
9540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ReturnedClass{$LibVersion}{$Tid} = 1;
9541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
9544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ReturnedClass{$LibVersion}{$Base{"Tid"}} = 1;
9545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9548850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Num (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
9549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9550850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $PId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Num}{"type"};
955162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(get_PLevel($PId, $LibVersion)>=1)
9552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
955362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my %Base = get_BaseType($PId, $LibVersion))
9554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
95551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if($Base{"Type"}=~/Struct|Class/)
95561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    {
9557850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        $ParamClass{$LibVersion}{$Base{"Tid"}}{$Symbol} = 1;
95581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        foreach my $SubId (get_sub_classes($Base{"Tid"}, $LibVersion, 1))
95591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # mark all derived classes
9560850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            $ParamClass{$LibVersion}{$SubId}{$Symbol} = 1;
95611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        }
9562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
9563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
95669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
95679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        # mapping {short name => symbols}
95689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Func_ShortName{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"ShortName"}}{$Symbol} = 1;
9569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
9570dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $MnglName (keys(%VTableClass))
957174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # reconstruct attributes of v-tables
95729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($MnglName, "_ZTV")==0)
9573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9574dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $ClassName = $VTableClass{$MnglName})
9575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
957674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
957774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
957862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Header"} = $TypeInfo{$LibVersion}{$ClassId}{"Header"};
957974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CompleteSignature{$LibVersion}{$MnglName}{"Class"} = $ClassId;
9580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
9581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
95841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
95851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # types
958662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (keys(%{$TypeInfo{$LibVersion}}))
95871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
958862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"})
95891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
959062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"}) {
959162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
95921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
959362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"Base"})
95941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
959562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $ClassNames{$LibVersion}{$TName} = 1;
959662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $Bid (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"Base"}}))
95971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                {
959862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(my $BName = $TypeInfo{$LibVersion}{$Bid}{"Name"}) {
959962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $ClassNames{$LibVersion}{$BName} = 1;
96001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    }
96011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
96021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
96031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
96041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
9605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
9606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
9607177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub getFirst($$)
9608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
9609177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
9610177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Tid) {
9611177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return $Tid;
9612177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9613177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9614177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"})
9615177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9616177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TName_Tid{$LibVersion}{$Name}) {
9617177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return $TName_Tid{$LibVersion}{$Name};
9618177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9619177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9620177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9621177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    return $Tid;
9622177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9623177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9624177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_SymbolUsage($$$)
9625177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9626177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($InfoId, $UsedType, $LibVersion) = @_;
9627177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9628177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %FuncInfo = %{$SymbolInfo{$LibVersion}{$InfoId}};
9629177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $RTid = getFirst($FuncInfo{"Return"}, $LibVersion))
9630177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9631177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($RTid, $UsedType, $LibVersion);
9632177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Return"} = $RTid;
9633177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9634177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(my $FCid = getFirst($FuncInfo{"Class"}, $LibVersion))
9635177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9636177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_TypeUsage($FCid, $UsedType, $LibVersion);
9637177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        $SymbolInfo{$LibVersion}{$InfoId}{"Class"} = $FCid;
9638177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9639177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."*const", $LibVersion))
9640177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer
9641177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId, $UsedType, $LibVersion);
9642177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9643177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $ThisId_C = getTypeIdByName($TypeInfo{$LibVersion}{$FCid}{"Name"}."const*const", $LibVersion))
9644177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # register "this" pointer (const method)
9645177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($ThisId_C, $UsedType, $LibVersion);
9646177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9647177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9648177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $PPos (keys(%{$FuncInfo{"Param"}}))
9649177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9650177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $PTid = getFirst($FuncInfo{"Param"}{$PPos}{"type"}, $LibVersion))
9651177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9652177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($PTid, $UsedType, $LibVersion);
9653177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $FuncInfo{"Param"}{$PPos}{"type"} = $PTid;
9654177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9655177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9656177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $TPos (keys(%{$FuncInfo{"TParam"}}))
9657177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9658177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        my $TPName = $FuncInfo{"TParam"}{$TPos}{"name"};
9659177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9660177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($TTid, $UsedType, $LibVersion);
9661177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9662177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9663177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
9664177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9665177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub register_TypeUsage($$$)
9666177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
9667177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($TypeId, $UsedType, $LibVersion) = @_;
966862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $TypeId) {
9669177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9670989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9671177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($UsedType->{$TypeId})
9672989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # already registered
9673177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
9674989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
9675177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
967662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %TInfo = get_Type($TypeId, $LibVersion);
9677850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($TInfo{"Type"})
9678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9679177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(my $NS = $TInfo{"NameSpace"})
9680177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9681177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $NSTid = $TName_Tid{$LibVersion}{$NS}) {
9682177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($NSTid, $UsedType, $LibVersion);
9683177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9684177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9685177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9686177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($TInfo{"Type"}=~/\A(Struct|Union|Class|FuncPtr|Func|MethodPtr|FieldPtr|Enum)\Z/)
9687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
9688177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9689850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"}=~/\A(Struct|Class)\Z/)
9690989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9691177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $BaseId (keys(%{$TInfo{"Base"}})) {
9692177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($BaseId, $UsedType, $LibVersion);
9693989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9694850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $TPos (keys(%{$TInfo{"TParam"}}))
9695850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                {
9696850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    my $TPName = $TInfo{"TParam"}{$TPos}{"name"};
9697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(my $TTid = $TName_Tid{$LibVersion}{$TPName}) {
9698177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($TTid, $UsedType, $LibVersion);
9699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    }
9700850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
97011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9702850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            foreach my $Memb_Pos (keys(%{$TInfo{"Memb"}}))
9703989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
9704177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $MTid = getFirst($TInfo{"Memb"}{$Memb_Pos}{"type"}, $LibVersion))
9705177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9706177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($MTid, $UsedType, $LibVersion);
9707177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TInfo{"Memb"}{$Memb_Pos}{"type"} = $MTid;
9708989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
97091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
9710850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($TInfo{"Type"} eq "FuncPtr"
9711177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "MethodPtr"
9712177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            or $TInfo{"Type"} eq "Func")
9713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
9714850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9715177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9716989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9717177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $PPos (keys(%{$TInfo{"Param"}}))
9718989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
9719177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(my $PTid = $TInfo{"Param"}{$PPos}{"type"}) {
9720177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        register_TypeUsage($PTid, $UsedType, $LibVersion);
9721989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    }
9722989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
9723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
9724177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "FieldPtr")
9725177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9726177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $RTid = $TInfo{"Return"}) {
9727177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($RTid, $UsedType, $LibVersion);
9728177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9729177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9730177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9731177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9732177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9733177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TInfo{"Type"} eq "MethodPtr")
9734177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9735177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(my $CTid = $TInfo{"Class"}) {
9736177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    register_TypeUsage($CTid, $UsedType, $LibVersion);
9737177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9738177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9740850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($TInfo{"Type"}=~/\A(Const|ConstVolatile|Volatile|Pointer|Ref|Restrict|Array|Typedef)\Z/)
9741989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        {
9742177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
9743177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $BTid = getFirst($TInfo{"BaseType"}, $LibVersion))
9744177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9745177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($BTid, $UsedType, $LibVersion);
9746177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $BTid;
9747177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
97481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
9749177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
9750177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # Intrinsic, TemplateParam, TypeName, SizeOf, etc.
9751177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            $UsedType->{$TypeId} = 1;
97521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
97531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
97541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
97551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
9756850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub selectSymbol($$$$)
975735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko{ # select symbol to check or to dump
9758850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Symbol, $SInfo, $Level, $LibVersion) = @_;
9759850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
976035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    if($Level eq "Dump")
976135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    {
976235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($SInfo->{"Virt"} or $SInfo->{"PureVirt"})
976335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        { # TODO: check if this symbol is from
976435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko          # base classes of other target symbols
976535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            return 1;
976635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
976735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    }
976835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko
9769850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(not $STDCXX_TESTING and $Symbol=~/\A(_ZS|_ZNS|_ZNKS)/)
9770850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # stdc++ interfaces
9771850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return 0;
97720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
9773850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9774850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my $Target = 0;
9775850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(my $Header = $SInfo->{"Header"}) {
9776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Target = (is_target_header($Header, 1) or is_target_header($Header, 2));
9777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
97788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($ExtendedCheck)
97798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
9780c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        if(index($Symbol, "external_func_")==0) {
97818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Target = 1;
97828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
97838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
9784177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($CheckHeadersOnly or $Level eq "Source")
9785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9786850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Target)
9787850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
9788850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Dump")
9789850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # dumped
9790850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($BinaryOnly)
97910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
9792850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    if(not $SInfo->{"InLine"} or $SInfo->{"Data"}) {
97930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        return 1;
97940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
97950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
9796850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                else {
9797850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9798850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
97990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
9800850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Source")
9801850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9802850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
9803850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9804850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Level eq "Binary")
9805850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # checked
9806850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $SInfo->{"InLine"} or $SInfo->{"Data"}
9807850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $SInfo->{"Virt"} or $SInfo->{"PureVirt"}) {
9808850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9809850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9810850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9811850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9812850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
9813850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else
9814850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # library is available
9815850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(link_symbol($Symbol, $LibVersion, "-Deps"))
9816850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # exported symbols
9817850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
9818850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9819850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Dump")
9820850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # dumped
982135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            if($BinaryOnly)
982235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            {
982335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($SInfo->{"Data"})
982435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                {
982535c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    if($Target) {
982635c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                        return 1;
982735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    }
9828850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9829850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
983035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            else
983135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # SrcBin
9832850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9833850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9834850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9835850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9836850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9837850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Source")
9838850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
983901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"} or $SInfo->{"InLine"}
984001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            or isInLineInst($Symbol, $SInfo, $LibVersion))
984135c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            { # skip LOCAL symbols
984235c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                if($Target) {
984335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                    return 1;
984435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko                }
98450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
98460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
9847850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        elsif($Level eq "Binary")
9848850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # checked
9849850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SInfo->{"PureVirt"} or $SInfo->{"Data"})
9850850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
9851850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Target) {
9852850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
9853850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
9854850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9855850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
98560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
98570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return 0;
98580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
98590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
9860850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub cleanDump($)
9861850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # clean data
9862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
98631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
9864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
9865177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}}))
9866177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9867177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9868177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9869177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
98701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
9871177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $MnglName)
9872177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
98731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
9875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9876850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $ShortName = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
9877177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ShortName)
9878177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9879989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId});
9880989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
9881989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
9882850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($MnglName eq $ShortName)
9883850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # remove duplicate data
98841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"MnglName"});
9885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
9886850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}})) {
9887850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"Param"});
9888850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
988901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"TParam"}})) {
989001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($SymbolInfo{$LibVersion}{$InfoId}{"TParam"});
989101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9892f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        delete($SymbolInfo{$LibVersion}{$InfoId}{"Type"});
9893850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
989462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
9895850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9896177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}}))
9897177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9898177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
9899177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9900177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
990101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid}{"Tid"});
990262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Attr ("Header", "Line", "Size", "NameSpace")
9903850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
990462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $TypeInfo{$LibVersion}{$Tid}{$Attr}) {
990562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{$Attr});
9906850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
9907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
990801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not keys(%{$TypeInfo{$LibVersion}{$Tid}{"TParam"}})) {
990901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TParam"});
991001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
9911850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
991262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
991362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
991462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selectType($$)
991562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
991662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Tid, $LibVersion) = @_;
99179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
99189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $Dupl = $TypeTypedef{$LibVersion}{$Tid})
99199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
99209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$Dupl})
99219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
99229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Dupl}{"Name"} eq $TypeInfo{$LibVersion}{$Tid}{"Name"})
99239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # duplicate
99249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return 0;
99259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
99269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
99279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
99289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
992962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $THeader = $TypeInfo{$LibVersion}{$Tid}{"Header"})
9930850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
993162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not isBuiltIn($THeader))
993262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
993362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TypeInfo{$LibVersion}{$Tid}{"Type"}=~/Class|Struct|Union|Enum|Typedef/)
993462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
993562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not isAnon($TypeInfo{$LibVersion}{$Tid}{"Name"}))
993662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
993762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(is_target_header($THeader, $LibVersion))
993862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # from target headers
993962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(not selfTypedef($Tid, $LibVersion)) {
994062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            return 1;
994162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        }
994262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
994362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
994462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
9945850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
9946850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
994762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
9948850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
9949850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
9950177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub remove_Unused($$)
9951850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{ # remove unused data types from the ABI dump
9952850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($LibVersion, $Kind) = @_;
9953177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9954177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %UsedType = ();
9955177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9956177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $InfoId (sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}}))
9957850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
9958177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        register_SymbolUsage($InfoId, \%UsedType, $LibVersion);
9959177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9960177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9961177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
9962177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9963177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
9964177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
9965177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9966177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9967177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extended")
9968177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
9969177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(selectType($Tid, $LibVersion))
9970177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
9971177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my %Tree = ();
9972177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                register_TypeUsage($Tid, \%Tree, $LibVersion);
9973177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9974177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                my $Tmpl = 0;
9975177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach (sort {int($a)<=>int($b)} keys(%Tree))
9976177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9977177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
9978177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
9979177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    {
9980177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $Tmpl = 1;
9981177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        last;
9982177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9983177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9984177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(not $Tmpl)
9985177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
9986177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    foreach (keys(%Tree)) {
9987177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $UsedType{$_} = 1;
9988177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    }
9989177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
9990177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
9991177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
9992177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
9993177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9994177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my %Delete = ();
9995177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
9996177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
9997177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove unused types
9998177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($UsedType{$Tid})
9999177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # All & Extended
10000177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            next;
10001989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
10002177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10003177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($Kind eq "Extra")
10004850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10005177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my %Tree = ();
10006177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            register_TypeUsage($Tid, \%Tree, $LibVersion);
10007177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10008177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            foreach (sort {int($a)<=>int($b)} keys(%Tree))
10009177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
10010177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $TypeInfo{$LibVersion}{$_}{"Template"}
10011177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                or $TypeInfo{$LibVersion}{$_}{"Type"} eq "TemplateParam")
10012177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                {
10013177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $Delete{$Tid} = 1;
10014177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    last;
10015850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10016850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10017989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
10018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        else
10019177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
10020177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            # remove type
10021177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid});
10022177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
10023177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10024177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10025177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if($Kind eq "Extra")
10026177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # remove duplicates
10027177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
10028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($UsedType{$Tid})
10030177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            { # All & Extended
10031177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10032177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10033177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $Name = $TypeInfo{$LibVersion}{$Tid}{"Name"};
10035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName_Tid{$LibVersion}{$Name} ne $Tid) {
10037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid});
10038989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
10039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10040177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10041177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10042177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    foreach my $Tid (keys(%Delete))
10043177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10044177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TypeInfo{$LibVersion}{$Tid});
10045177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10046177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
10047177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10048177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_Completeness($$)
10049177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
10050177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Info, $LibVersion) = @_;
10051177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10052177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # data types
10053177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Memb"})
10054177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10055177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Memb"}}))
10056850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10057177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Memb"}{$Pos}{"type"}) {
10058177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Memb"}{$Pos}{"type"}, $LibVersion);
10059850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10062177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Base"})
1006362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
10064177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Bid (keys(%{$Info->{"Base"}})) {
10065177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            check_TypeInfo($Bid, $LibVersion);
1006662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
10067177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10068177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"BaseType"}) {
10069177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"BaseType"}, $LibVersion);
10070177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10071177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"TParam"})
10072177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10073177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"TParam"}}))
10074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10075177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            my $TName = $Info->{"TParam"}{$Pos}{"name"};
10076177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\A\(.+\)(true|false|\d.*)\Z/) {
10077177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10078177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10079177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName eq "_BoolType") {
10080177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10081177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10082177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if($TName=~/\Asizeof\(/) {
10083177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                next;
10084177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10085177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(my $Tid = $TName_Tid{$LibVersion}{$TName}) {
10086177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Tid, $LibVersion);
10087177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
10088177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            else
10089177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
10090177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                if(defined $Debug) {
10091177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    printMsg("WARNING", "missed type $TName");
10092177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
10093850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10096177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10097177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    # symbols
10098177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Param"})
10099177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10100177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Pos (keys(%{$Info->{"Param"}}))
10101177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
10102177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $Info->{"Param"}{$Pos}{"type"}) {
10103177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                check_TypeInfo($Info->{"Param"}{$Pos}{"type"}, $LibVersion);
10104177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
1010562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1010662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
10107177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Return"}) {
10108177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Return"}, $LibVersion);
10109177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10110177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $Info->{"Class"}) {
10111177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_TypeInfo($Info->{"Class"}, $LibVersion);
10112177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10113177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko}
10114177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10115177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenkosub check_TypeInfo($$)
10116177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko{
10117177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    my ($Tid, $LibVersion) = @_;
10118850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
10119177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $CheckedTypeInfo{$LibVersion}{$Tid}) {
10120177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        return;
10121177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10122177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $CheckedTypeInfo{$LibVersion}{$Tid} = 1;
10123177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
10124177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(defined $TypeInfo{$LibVersion}{$Tid})
10125177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    {
10126177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $TypeInfo{$LibVersion}{$Tid}{"Name"}) {
10127177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            printMsg("ERROR", "missed type name ($Tid)");
10128177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
10129177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        check_Completeness($TypeInfo{$LibVersion}{$Tid}, $LibVersion);
10130177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10131177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    else {
10132177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        printMsg("ERROR", "missed type id $Tid");
10133177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
10134850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko}
10135850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1013662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub selfTypedef($$)
10137850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko{
1013862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1013962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = get_Type($TypeId, $LibVersion);
10140850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type{"Type"} eq "Typedef")
10141dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    {
10142f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base = get_OneStep_BaseType($TypeId, $TypeInfo{$LibVersion});
10143850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base{"Type"}=~/Class|Struct/)
10144850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10145850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Type{"Name"} eq $Base{"Name"}) {
10146850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                return 1;
10147850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10148850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            elsif($Type{"Name"}=~/::(\w+)\Z/)
10149850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10150850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Type{"Name"} eq $Base{"Name"}."::".$1)
10151850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # QPointer<QWidget>::QPointer
10152850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    return 1;
10153850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10154850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10155dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
10156dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
10157850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
10158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
101601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub addExtension($)
10161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
101621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
101638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Tid (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
10164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1016562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(selectType($Tid, $LibVersion))
10166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
101678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$Tid}{"Name"};
101688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $TName=~s/\A(struct|union|class|enum) //;
101698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Symbol = "external_func_".$TName;
1017062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1017162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            %{$CompleteSignature{$LibVersion}{$Symbol}} = (
1017262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Header" => "extended.h",
1017362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "ShortName" => $Symbol,
1017462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "MnglName" => $Symbol,
1017562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "Param" => { 0 => { "type"=>$Tid, "name"=>"p1" } }
1017662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1017762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
101788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ExtendedSymbols{$Symbol} = 1;
101798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
101808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CheckedSymbols{"Source"}{$Symbol} = 1;
10181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
101838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $ExtendedSymbols{"external_func_0"} = 1;
101848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Binary"}{"external_func_0"} = 1;
101858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $CheckedSymbols{"Source"}{"external_func_0"} = 1;
10186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod($$$)
10189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1019162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $BaseClass_Id (keys(%{$TypeInfo{$LibVersion}{$ClassId}{"Base"}}))
10192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VirtMethodInClass = findMethod_Class($VirtFunc, $BaseClass_Id, $LibVersion)) {
10194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInClass;
10195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(my $VirtMethodInBaseClasses = findMethod($VirtFunc, $BaseClass_Id, $LibVersion)) {
10197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VirtMethodInBaseClasses;
10198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub findMethod_Class($$$)
10204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($VirtFunc, $ClassId, $LibVersion) = @_;
1020662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
10207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not defined $VirtualTable{$LibVersion}{$ClassName});
10208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetSuffix = get_symbol_suffix($VirtFunc, 1);
10209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TargetShortName = $CompleteSignature{$LibVersion}{$VirtFunc}{"ShortName"};
10210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Candidate (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for interface with the same parameters suffix (overridden)
10212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetSuffix eq get_symbol_suffix($Candidate, 1))
10213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10214e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"Destructor"})
10215e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10216989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Candidate}{"Destructor"})
10217989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(($VirtFunc=~/D0E/ and $Candidate=~/D0E/)
10219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D1E/ and $Candidate=~/D1E/)
10220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($VirtFunc=~/D2E/ and $Candidate=~/D2E/)) {
10221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return $Candidate;
10222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10225e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            else
10226e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            {
10227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($TargetShortName eq $CompleteSignature{$LibVersion}{$Candidate}{"ShortName"}) {
10228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return $Candidate;
10229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
10234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
102361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub registerVTable($)
10237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
102381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $LibVersion = $_[0];
102391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompleteSignature{$LibVersion}}))
10240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
102411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Virt"}
102421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{$LibVersion}{$Symbol}{"PureVirt"})
10243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1024462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ClassName = $TypeInfo{$LibVersion}{$CompleteSignature{$LibVersion}{$Symbol}{"Class"}}{"Name"};
10245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $STDCXX_TESTING and $ClassName=~/\A(std::|__cxxabi)/);
102461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$Symbol}{"Destructor"}
102471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Symbol=~/D2E/)
10248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # pure virtual D2-destructors are marked as "virt" in the dump
10249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # virtual D2-destructors are NOT marked as "virt" in the dump
10250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # both destructors are not presented in the v-table
10251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
10252ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
102531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
10254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $VirtualTable{$LibVersion}{$ClassName}{$MnglName} = 1;
10255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10256ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub registerOverriding($)
10260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Classes = keys(%{$VirtualTable{$LibVersion}});
10263850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Classes = sort {int($TName_Tid{$LibVersion}{$a})<=>int($TName_Tid{$LibVersion}{$b})} @Classes;
10264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (@Classes)
10265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $VirtFunc (keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
102681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($CompleteSignature{$LibVersion}{$VirtFunc}{"PureVirt"})
102691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # pure virtuals
102701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                next;
102711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
102721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $ClassId = $TName_Tid{$LibVersion}{$ClassName};
102731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(my $Overridden = findMethod($VirtFunc, $ClassId, $LibVersion))
10274850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10275850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Overridden}{"Virt"}
10276850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                or $CompleteSignature{$LibVersion}{$Overridden}{"PureVirt"})
10277850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # both overridden virtual methods
10278850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                  # and implemented pure virtual methods
10279850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $CompleteSignature{$LibVersion}{$VirtFunc}{"Override"} = $Overridden;
10280850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $OverriddenMethods{$LibVersion}{$Overridden}{$VirtFunc} = 1;
10281850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    delete($VirtualTable{$LibVersion}{$ClassName}{$VirtFunc}); # remove from v-table model
10282850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not keys(%{$VirtualTable{$LibVersion}{$ClassName}})) {
10286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($VirtualTable{$LibVersion}{$ClassName});
10287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub setVirtFuncPositions($)
10292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
10294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{$LibVersion}}))
10295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10296fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my ($Num, $Rel) = (1, 0);
10297fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10298fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Funcs = sort keys(%{$VirtualTable{$LibVersion}{$ClassName}}))
10299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UsedDump{$LibVersion}{"DWARF"}) {
10301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @Funcs;
10302fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
10304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                @Funcs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @Funcs;
10305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
10306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $VirtFunc (@Funcs)
10307fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
10308fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10309fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $CompleteSignature{$LibVersion}{$VirtFunc}{"VirtPos"};
10310fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10311fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10312fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $VirtualTable{$LibVersion}{$ClassName}{$VirtFunc} = $Num++;
10313fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10314fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
10315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # set relative positions
10316fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(defined $VirtualTable{1}{$ClassName} and defined $VirtualTable{1}{$ClassName}{$VirtFunc}
10317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and defined $VirtualTable{2}{$ClassName} and defined $VirtualTable{2}{$ClassName}{$VirtFunc})
10318fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # relative position excluding added and removed virtual functions
10319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $CompleteSignature{1}{$VirtFunc}{"Override"}
10320fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $CompleteSignature{2}{$VirtFunc}{"Override"}) {
10321fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $CompleteSignature{$LibVersion}{$VirtFunc}{"RelPos"} = $Rel++;
10322fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
10323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
103271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{$LibVersion}}))
10328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $AbsNum = 1;
103301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $VirtFunc (getVTable_Model($TName_Tid{$LibVersion}{$ClassName}, $LibVersion)) {
10331fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $VirtualTable_Model{$LibVersion}{$ClassName}{$VirtFunc} = $AbsNum++;
10332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_sub_classes($$$)
10337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
10339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $Class_SubClasses{$LibVersion}{$ClassId});
10340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Subs = ();
10341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubId (keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
10342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
103431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
103441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubSubId (get_sub_classes($SubId, $LibVersion, $Recursive)) {
10346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Subs, $SubSubId);
10347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Subs, $SubId);
10350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Subs;
10352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_base_classes($$$)
10355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion, $Recursive) = @_;
1035762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %ClassType = get_Type($ClassId, $LibVersion);
10358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not defined $ClassType{"Base"});
10359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = ();
10360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (sort {int($ClassType{"Base"}{$a}{"pos"})<=>int($ClassType{"Base"}{$b}{"pos"})}
10361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    keys(%{$ClassType{"Base"}}))
10362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
103631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Recursive)
103641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
10365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $SubBaseId (get_base_classes($BaseId, $LibVersion, $Recursive)) {
10366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Bases, $SubBaseId);
10367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Bases, $BaseId);
10370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Bases;
10372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
103741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Model($$)
103751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # return an ordered list of v-table elements
10376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Elements = ();
10379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases, $ClassId)
10380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1038162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10382850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10383850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName})
10384850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my @VFuncs = keys(%{$VirtualTable{$LibVersion}{$BName}});
10386fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UsedDump{$LibVersion}{"DWARF"}) {
10387fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"VirtPos"}) <=> int($CompleteSignature{$LibVersion}{$b}{"VirtPos"})} @VFuncs;
10388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
10390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    @VFuncs = sort {int($CompleteSignature{$LibVersion}{$a}{"Line"}) <=> int($CompleteSignature{$LibVersion}{$b}{"Line"})} @VFuncs;
10391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
10392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $VFunc (@VFuncs) {
10393850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    push(@Elements, $VFunc);
10394850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10395850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Elements;
10399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getVShift($$)
10402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 1);
10405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VShift = 0;
10406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1040862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"})
10409850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
10410850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(defined $VirtualTable{$LibVersion}{$BName}) {
10411850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $VShift+=keys(%{$VirtualTable{$LibVersion}{$BName}});
10412850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VShift;
10416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getShift($$)
10419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Bases = get_base_classes($ClassId, $LibVersion, 0);
10422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Shift = 0;
10423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $BaseId (@Bases)
10424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1042562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Size = $TypeInfo{$LibVersion}{$BaseId}{"Size"})
10426dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
10427dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Size!=1)
10428dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # not empty base class
10429dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                $Shift+=$Size;
10430dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
10431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Shift;
10434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
104361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Size($$)
104371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # number of v-table elements
10438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
104391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Size = 0;
104401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # three approaches
104411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
104421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # real size
104431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(my %VTable = getVTable_Real($ClassName, $LibVersion)) {
104441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%VTable);
104451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
104481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # shared library symbol size
104491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Size = getSymbolSize($ClassVTable{$ClassName}, $LibVersion)) {
104501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size /= $WORD_SIZE{$LibVersion};
104511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
10452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
104531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Size)
104541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # model size
104551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $VirtualTable_Model{$LibVersion}{$ClassName}) {
104561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Size = keys(%{$VirtualTable_Model{$LibVersion}{$ClassName}}) + 2;
104571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
104581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
104591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Size;
10460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCopyingClass($$)
10463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1046562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return $TypeInfo{$LibVersion}{$TypeId}{"Copied"};
10466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLeafClass($$)
10469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
10471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (not keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}));
10472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub havePubFields($)
10475dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check structured type for public fields
10476dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return isAccessible($_[0], {}, 0, -1);
10477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isAccessible($$$$)
10480dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{ # check interval in structured type for public fields
10481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $Skip, $Start, $End) = @_;
10482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($End==-1) {
10484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $End = keys(%{$TypePtr->{"Memb"}})-1;
10485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemPos (keys(%{$TypePtr->{"Memb"}}))
10487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
10488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Skip and $Skip->{$MemPos})
10489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip removed/added fields
10490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($MemPos)>=$Start and int($MemPos)<=$End)
10493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
10494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isPublic($TypePtr, $MemPos)) {
10495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return ($MemPos+1);
10496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isReserved($)
10503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # reserved fields == private
10504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MName = $_[0];
10505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/reserved|padding|f_spare/i) {
10506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($MName=~/\A[_]*(spare|pad|unused)[_\d]*\Z/i) {
10509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MName=~/(pad\d+)/i) {
10512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
10517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isPublic($$)
10518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypePtr, $FieldPos) = @_;
10520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypePtr);
10521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos});
10522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not defined $TypePtr->{"Memb"}{$FieldPos}{"name"});
10523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TypePtr->{"Memb"}{$FieldPos}{"access"})
10524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by name in C language
10525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # FIXME: add other methods to detect private members
10526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $MName = $TypePtr->{"Memb"}{$FieldPos}{"name"};
10527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MName=~/priv|abidata|parent_object/i)
10528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C-styled private data
10529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(lc($MName) eq "abi")
10532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # ABI information/reserved field
10533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isReserved($MName))
10536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # reserved fields
10537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
10538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($TypePtr->{"Memb"}{$FieldPos}{"access"} ne "private")
10542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # by access in C++ language
10543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
10544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getVTable_Real($$)
105491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
105501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($ClassName, $LibVersion) = @_;
105511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(my $ClassId = $TName_Tid{$LibVersion}{$ClassName})
105521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
1055362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type = get_Type($ClassId, $LibVersion);
105541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Type{"VTable"}) {
105551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return %{$Type{"VTable"}};
105561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
105571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
105581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ();
105591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
105601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
105611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables($)
105621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
105631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ClassName = $_[0];
105641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Res = cmpVTables_Real($ClassName, 1);
105651693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Res==-1) {
105661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Res = cmpVTables_Model($ClassName);
105671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
105681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Res;
105691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
105701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
10571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVTables_Model($)
10572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ClassName = $_[0];
105741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $Symbol (keys(%{$VirtualTable_Model{1}{$ClassName}}))
10575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol}) {
10577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
10578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
10581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
105831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub cmpVTables_Real($$)
10584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
10585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassName, $Strong) = @_;
105861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"cmpVTables_Real"}{$Strong}{$ClassName}) {
105871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"cmpVTables_Real"}{$Strong}{$ClassName};
10588dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
105891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_Old = getVTable_Real($ClassName, 1);
105901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %VTable_New = getVTable_Real($ClassName, 2);
105911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not %VTable_Old or not %VTable_New)
10592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old ABI dumps
105931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = -1);
10594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
105951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Indexes = map {$_=>1} (keys(%VTable_Old), keys(%VTable_New));
10596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Offset (sort {int($a)<=>int($b)} keys(%Indexes))
10597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
105981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_Old{$Offset})
10599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 < v-table v.2
106001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = $Strong);
10601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
106021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry1 = $VTable_Old{$Offset};
106031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not defined $VTable_New{$Offset})
10604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # v-table v.1 > v-table v.2
106051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = ($Strong or $Entry1!~/__cxa_pure_virtual/));
10606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
106071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Entry2 = $VTable_New{$Offset};
10608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry1 = simpleVEntry($Entry1);
10609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Entry2 = simpleVEntry($Entry2);
10610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Entry1 ne $Entry2)
10611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register as changed
10612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Entry1=~/::([^:]+)\Z/)
10613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
10614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $M1 = $1;
10615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Entry2=~/::([^:]+)\Z/)
10616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $M2 = $1;
10618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($M1 eq $M2)
10619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # overridden
10620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10624989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            if(differentDumps("G"))
10625989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            {
10626989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                if($Entry1=~/\A\-(0x|\d+)/ and $Entry2=~/\A\-(0x|\d+)/)
10627989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                {
10628989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.6.1: -0x00000000000000010
10629989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    # GCC 4.7.0: -16
10630989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    next;
10631989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                }
10632989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            }
106331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 1);
10634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
106361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"cmpVTables_Real"}{$Strong}{$ClassName} = 0);
10637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
106391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVTables($)
10640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # merging v-tables without diagnostics
106411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
10642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $ClassName (keys(%{$VirtualTable{1}}))
10643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
106441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($VTableChanged_M{$ClassName})
10645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # already registered
10646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
106481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(cmpVTables_Real($ClassName, 0)==1)
10649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
10651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (@Affected)
10652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
106531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Virtual_Table_Changed_Unknown"}{$ClassName}}=(
10654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$ClassName,
10655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$ClassName);
10656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
10659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
10660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
106611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeBases($)
10662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
106631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
106641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (keys(%{$ClassNames{1}}))
10665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added and removed virtual functions
106661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId = $TName_Tid{1}{$ClassName};
10667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId);
10668dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{2}{$ClassName})
10669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{2}{$ClassName}}))
10671dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{1}{$ClassName}
106731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{1}{$ClassName}{$Symbol})
10674dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # added to v-table
106751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{1}{$Symbol}
106761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{1}{$Symbol}{"Virt"})
106771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.1
106781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10679dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $AddedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10684dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(defined $VirtualTable{1}{$ClassName})
10685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
106861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Symbol (keys(%{$VirtualTable{1}{$ClassName}}))
10687dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
106881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($TName_Tid{2}{$ClassName}
106891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                and not defined $VirtualTable{2}{$ClassName}{$Symbol})
10690dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # removed from v-table
106911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$Symbol}
106921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and $CompleteSignature{2}{$Symbol}{"Virt"})
106931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    { # override some method in v.2
106941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        next;
10695dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
106961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $RemovedInt_Virt{$Level}{$ClassName}{$Symbol} = 1;
10697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
107001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
107011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
1070262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Class_Type = get_Type($ClassId, 1);
107031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$ClassName}}))
107041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # check replacements, including pure virtual methods
107051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $AddedPos = $VirtualTable{2}{$ClassName}{$AddedVFunc};
107061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$ClassName}}))
10707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $RemovedPos = $VirtualTable{1}{$ClassName}{$RemovedVFunc};
107091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($AddedPos==$RemovedPos)
107101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
107111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$AddedVFunc} = $RemovedVFunc;
107121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $VirtualReplacement{$RemovedVFunc} = $AddedVFunc;
107131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        last; # other methods will be reported as "added" or "removed"
10714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
107161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $RemovedVFunc = $VirtualReplacement{$AddedVFunc})
10717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
107181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(lc($AddedVFunc) eq lc($RemovedVFunc))
107191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # skip: DomUi => DomUI parameter (Qt 4.2.3 to 4.3.0)
10720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
10721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
107221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ProblemType = "Virtual_Replacement";
107231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @Affected = ($RemovedVFunc);
107241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
107251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # pure methods
107261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not isUsedClass($ClassId, 1, $Level))
107271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # not a parameter of some exported method
107281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
107291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemType = "Pure_Virtual_Replacement";
107319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
107329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        # affected all methods (both virtual and non-virtual ones)
107339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        @Affected = (keys(%{$ClassMethods{$Level}{1}{$ClassName}}));
107349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        push(@Affected, keys(%{$OverriddenMethods{1}{$RemovedVFunc}}));
107351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
107369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $VTableChanged_M{$ClassName}=1;
107371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $AffectedInt (@Affected)
107381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
107391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$AffectedInt}{"PureVirt"})
107401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # affected exported methods only
107411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
107421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
107439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(not symbolFilter($AffectedInt, 1, "Affected", $Level)) {
107449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
107459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
107461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$AffectedInt}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
107471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$Class_Type{"Name"},
107481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2),
107491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>get_Signature($RemovedVFunc, 1));
107501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
10751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1075562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "2.0")
1075662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    or not checkDump(2, "2.0"))
107571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # support for old ABI dumps
107589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # "Base" attribute introduced in ACC 1.22 (ABI dump 2.0 format)
10759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
10760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
107611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $ClassName (sort keys(%{$ClassNames{1}}))
10762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
107631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_Old = $TName_Tid{1}{$ClassName};
10764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $ClassId_Old);
10765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not isCreatable($ClassId_Old, 1))
10766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip classes without public constructors (including auto-generated)
10767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # example: class has only a private exported or private inline constructor
10768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ClassName=~/>/)
10771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip affected template instances
10772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
10773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1077462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_Old = get_Type($ClassId_Old, 1);
107751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $ClassId_New = $TName_Tid{2}{$ClassName};
10776850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $ClassId_New) {
10777850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
10778850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
1077962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Class_New = get_Type($ClassId_New, 2);
10780850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Class_New{"Type"}!~/Class|Struct/)
10781850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # became typedef
10782850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Binary") {
10783850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                next;
10784850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10785850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Level eq "Source")
10786850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
10787f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Class_New = get_PureType($ClassId_New, $TypeInfo{2});
10788850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if($Class_New{"Type"}!~/Class|Struct/) {
10789850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
10790850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
10791850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ClassId_New = $Class_New{"Tid"};
10792850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
10793850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
10794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_Old = sort {$Class_Old{"Base"}{$a}{"pos"}<=>$Class_Old{"Base"}{$b}{"pos"}} keys(%{$Class_Old{"Base"}});
10795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Bases_New = sort {$Class_New{"Base"}{$a}{"pos"}<=>$Class_New{"Base"}{$b}{"pos"}} keys(%{$Class_New{"Base"}});
10796f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10797f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_Old = map {$TypeInfo{1}{$_}{"Name"} => uncover_typedefs($TypeInfo{1}{$_}{"Name"}, 1)} @Bases_Old;
10798f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Tr_New = map {$TypeInfo{2}{$_}{"Name"} => uncover_typedefs($TypeInfo{2}{$_}{"Name"}, 2)} @Bases_New;
10799f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
10800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($BNum1, $BNum2) = (1, 1);
10801f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @Bases_Old;
10802f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BasePos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @Bases_New;
1080374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_Old = map {get_ShortClass($_, 1) => 1} @Bases_Old;
1080474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my %ShortBase_New = map {get_ShortClass($_, 2) => 1} @Bases_New;
10805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_Old = getShift($ClassId_Old, 1);
10806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Shift_New = getShift($ClassId_New, 2);
10807f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %BaseId_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @Bases_New;
10808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Added, $Removed) = (0, 0);
10809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_Old = ();
10810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_Old)
10811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1081262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10813f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_New{$Tr_Old{$BaseName}}) {
10814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_Old, $BaseId);
10815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10816f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_New{$Tr_Old{$BaseName}}
1081774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_New{get_ShortClass($BaseId, 1)})
10818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # removed base
10819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Removed_Base_Class";
108211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
108221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
108231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
108241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
108251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
108261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
108271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
108281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
108291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
108301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{1}{$BaseName}})
108331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
108341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
108351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
108361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
108391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10842f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10843f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10844f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10845f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10846f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10847f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
108529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
108539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
108549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
108551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Removed+=1;
10863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
10865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @StableBases_New = ();
10866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $BaseId (@Bases_New)
10867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1086862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $BaseName = $TypeInfo{2}{$BaseId}{"Name"};
10869f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($BasePos_Old{$Tr_New{$BaseName}}) {
10870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@StableBases_New, $BaseId);
10871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10872f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            elsif(not $ShortBase_Old{$Tr_New{$BaseName}}
1087374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and not $ShortBase_Old{get_ShortClass($BaseId, 2)})
10874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # added base
10875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # excluding namespace::SomeClass to SomeClass renaming
10876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemKind = "Added_Base_Class";
108771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
108781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Binary-level
108791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Shift_Old ne $Shift_New)
108801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected fields
108811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(havePubFields(\%Class_Old)) {
108821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Shift";
108831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
108841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($Class_Old{"Size"} ne $Class_New{"Size"}) {
108851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemKind .= "_And_Size";
108861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
108881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(keys(%{$VirtualTable_Model{2}{$BaseName}})
108891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and cmpVTables($ClassName)==1)
108901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # affected v-table
108911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $ProblemKind .= "_And_VTable";
108921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$ClassName}=1;
10893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
108951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @Affected = keys(%{$ClassMethods{$Level}{1}{$ClassName}});
10896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $SubId (get_sub_classes($ClassId_Old, 1, 1))
10897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
10898f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(my $SubName = $TypeInfo{1}{$SubId}{"Name"})
10899f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
10900f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        push(@Affected, keys(%{$ClassMethods{$Level}{1}{$SubName}}));
10901f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($ProblemKind=~/VTable/) {
10902f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            $VTableChanged_M{$SubName}=1;
10903f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
10904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@Affected)
10907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
109089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        next;
109109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
109111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{$ProblemKind}{"this"}}=(
10912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$ClassName,
10913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$BaseName,
10914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Class_Old{"Size"}*$BYTE_SIZE,
10915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Size"=>$Class_New{"Size"}*$BYTE_SIZE,
10916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Shift"=>abs($Shift_New-$Shift_Old)  );
10917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Added+=1;
10919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
10920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
109211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
109221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary-level
109231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            ($BNum1, $BNum2) = (1, 1);
10924f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_Old = map {$Tr_Old{$TypeInfo{1}{$_}{"Name"}} => $BNum1++} @StableBases_Old;
10925f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my %BaseRelPos_New = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $BNum2++} @StableBases_New;
109261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $BaseId (@Bases_Old)
10927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1092862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BaseName = $TypeInfo{1}{$BaseId}{"Name"};
10929f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if(my $NewPos = $BaseRelPos_New{$Tr_Old{$BaseName}})
109301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
10931f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $BaseNewId = $BaseId_New{$Tr_Old{$BaseName}};
10932f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $OldPos = $BaseRelPos_Old{$Tr_Old{$BaseName}};
109331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($NewPos!=$OldPos)
109341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed position of the base class
109351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Position"}{"this"}}=(
109411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName,
109431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$OldPos-1,
109441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Value"=>$NewPos-1  );
109451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
109471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Class_Old{"Base"}{$BaseId}{"virtual"}
109481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and not $Class_New{"Base"}{$BaseNewId}{"virtual"})
109491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became non-virtual base
109501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Non_Virtually_Inherited"}{"this->".$BaseName}}=(
109561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
109581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
109601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $Class_Old{"Base"}{$BaseId}{"virtual"}
109611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Class_New{"Base"}{$BaseNewId}{"virtual"})
109621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # became virtual base
109631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
109641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
109669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
109679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
109681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{"Base_Class_Became_Virtually_Inherited"}{"this->".$BaseName}}=(
109691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$ClassName,
109701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseName  );
109711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
10972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
10973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
10974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
109751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # detect size changes in base classes
109761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Shift_Old!=$Shift_New)
109771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # size of allocable class
109781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $BaseId (@StableBases_Old)
109791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # search for changed base
1098062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my %BaseType = get_Type($BaseId, 1);
1098162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Size_Old = $TypeInfo{1}{$BaseId}{"Size"};
10982f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my $Size_New = $TypeInfo{2}{$BaseId_New{$Tr_Old{$BaseType{"Name"}}}}{"Size"};
109831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Size_Old ne $Size_New
109841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Size_Old and $Size_New)
10985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
109861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "";
109871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isCopyingClass($BaseId, 1)) {
109881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Size_Of_Copying_Class";
10989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
109901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        elsif($AllocableClass{1}{$BaseType{"Name"}})
109911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
109921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Size_New>$Size_Old)
109931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # increased size
109941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Increased";
109951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
109961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            else
109971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # decreased size
109981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ProblemType = "Size_Of_Allocable_Class_Decreased";
109991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                if(not havePubFields(\%Class_Old))
110001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # affected class has no public members
110011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
110021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
11003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
110051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next if(not $ProblemType);
110061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Interface (keys(%{$ClassMethods{$Level}{1}{$ClassName}}))
110071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # base class size changes affecting current class
110089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            if(not symbolFilter($Interface, 1, "Affected", $Level)) {
110099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                next;
110109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            }
110111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Interface}{$ProblemType}{"this->".$BaseType{"Name"}}}=(
110121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Type_Name"=>$BaseType{"Name"},
110131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$BaseType{"Name"},
110141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Size"=>$Size_Old*$BYTE_SIZE,
110151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Size"=>$Size_New*$BYTE_SIZE  );
110161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11020f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if(defined $VirtualTable_Model{1}{$ClassName}
110211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            and cmpVTables_Real($ClassName, 1)==1
11022f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and my @VFunctions = keys(%{$VirtualTable_Model{1}{$ClassName}}))
110231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # compare virtual tables size in base classes
110241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_Old = getVShift($ClassId_Old, 1);
110251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $VShift_New = getVShift($ClassId_New, 2);
110261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($VShift_Old ne $VShift_New)
110271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # changes in the base class or changes in the list of base classes
110281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_Old = get_base_classes($ClassId_Old, 1, 1);
110291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @AllBases_New = get_base_classes($ClassId_New, 2, 1);
110301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    ($BNum1, $BNum2) = (1, 1);
11031f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    my %StableBase = map {$Tr_New{$TypeInfo{2}{$_}{"Name"}} => $_} @AllBases_New;
110321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $BaseId (@AllBases_Old)
11033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1103462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %BaseType = get_Type($BaseId, 1);
11035f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if(not $StableBase{$Tr_Old{$BaseType{"Name"}}})
110361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # lost base
110371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
11038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
110391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_Old = getVTable_Size($BaseType{"Name"}, 1);
110401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        my $VSize_New = getVTable_Size($BaseType{"Name"}, 2);
110411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($VSize_Old!=$VSize_New)
11042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
11043850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            foreach my $Symbol (@VFunctions)
11044f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            { # TODO: affected non-virtual methods?
11045f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if(not defined $VirtualTable_Model{2}{$ClassName}{$Symbol})
110461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # Removed_Virtual_Method, will be registered in mergeVirtualTables()
110471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
11048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11049850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($VirtualTable_Model{2}{$ClassName}{$Symbol}-$VirtualTable_Model{1}{$ClassName}{$Symbol}==0)
110501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # skip interfaces that have not changed the absolute virtual position
110511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next;
110521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
11053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
11054850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
110551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
110561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$BaseType{"Name"}} = 1;
110571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                $VTableChanged_M{$ClassName} = 1;
110581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$AddedInt_Virt{$Level}{$BaseType{"Name"}}}))
110591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: added virtual functions
110601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
110611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Added_Virtual_Method";
110621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{2}{$VirtFunc}{"PureVirt"}) {
110631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Added_Pure_Virtual_Method";
110641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
11065850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 2)}}=(
110661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 2)  );
110681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                }
110691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                foreach my $VirtFunc (keys(%{$RemovedInt_Virt{$Level}{$BaseType{"Name"}}}))
110701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                { # the reason of the layout change: removed virtual functions
110711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    next if($VirtualReplacement{$VirtFunc});
110721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    my $ProblemType = "Removed_Virtual_Method";
110731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    if($CompleteSignature{1}{$VirtFunc}{"PureVirt"}) {
110741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        $ProblemType = "Removed_Pure_Virtual_Method";
110751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    }
11076850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{get_Signature($VirtFunc, 1)}}=(
110771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Type_Name"=>$BaseType{"Name"},
110781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                        "Target"=>get_Signature($VirtFunc, 1)  );
11079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
11080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
11081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isCreatable($$)
11090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($ClassId, $LibVersion) = @_;
1109262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($AllocableClass{$LibVersion}{$TypeInfo{$LibVersion}{$ClassId}{"Name"}}
11093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or isCopyingClass($ClassId, $LibVersion)) {
11094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Class_SubClasses{$LibVersion}{$ClassId}}))
11097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Fix for incomplete data: if this class has
11098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # a base class then it should also has a constructor
11099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReturnedClass{$LibVersion}{$ClassId})
11102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # returned by some method of this class
11103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or any other class
11104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
111091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isUsedClass($$$)
11110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
111111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($ClassId, $LibVersion, $Level) = @_;
11112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$ParamClass{$LibVersion}{$ClassId}}))
11113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # parameter of some exported method
11114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1111662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{$LibVersion}{$ClassId}{"Name"};
1111762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(keys(%{$ClassMethods{$Level}{$LibVersion}{$CName}}))
11118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # method from target class
11119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
111241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeVirtualTables($$)
11125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # check for changes in the virtual table
111261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Interface, $Level) = @_;
111271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # affected methods:
11128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - virtual
11129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - pure-virtual
11130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  - non-virtual
11131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CompleteSignature{1}{$Interface}{"Data"})
11132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # global data is not affected
11133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
11134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Class_Id = $CompleteSignature{1}{$Interface}{"Class"};
111361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Class_Id) {
111371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
111381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
1113962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $CName = $TypeInfo{1}{$Class_Id}{"Name"};
111401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(cmpVTables_Real($CName, 1)==0)
111411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # no changes
111421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return;
111431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
111441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $CheckedTypes{$Level}{$CName} = 1;
111451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
111461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Binary-level
111471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Interface}{"PureVirt"}
111481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not isUsedClass($Class_Id, 1, $Level))
111491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # pure virtuals should not be affected
111500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # if there are no exported methods using this class
111511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return;
111521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
111530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
111540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach my $Func (keys(%{$VirtualTable{1}{$CName}}))
111550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
111560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $VirtualTable{2}{$CName}{$Func}
111570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and defined $CompleteSignature{2}{$Func})
111580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
111590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(not $CompleteSignature{1}{$Func}{"PureVirt"}
111600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$Func}{"PureVirt"})
111610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became pure virtual
111620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Pure"}{$tr_name{$Func}}}=(
111630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
111640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
111650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            elsif($CompleteSignature{1}{$Func}{"PureVirt"}
111680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and not $CompleteSignature{2}{$Func}{"PureVirt"})
111690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            { # became non-pure virtual
111700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Virtual_Method_Became_Non_Pure"}{$tr_name{$Func}}}=(
111710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Type_Name"=>$CName,
111720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>get_Signature_M($Func, 1)  );
111730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
111740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
111750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
111760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
111770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Level eq "Binary")
111780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # Binary-level
111791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        # check virtual table structure
111801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
111811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
111821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
111831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$AddedVFunc});
111841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $VPos_Added = $VirtualTable{2}{$CName}{$AddedVFunc};
111851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
111861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # pure virtual methods affect all others (virtual and non-virtual)
111871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$CName,
11189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
111901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
11191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11192dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif(not defined $VirtualTable{1}{$CName}
11193dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            or $VPos_Added>keys(%{$VirtualTable{1}{$CName}}))
111941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # added virtual function at the end of v-table
111951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not keys(%{$VirtualTable_Model{1}{$CName}}))
111961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # became polymorphous class, added v-table pointer
111971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Interface}{"Added_First_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$CName,
11199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>get_Signature($AddedVFunc, 2)  );
112001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    $VTableChanged_M{$CName} = 1;
11201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
112041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_Old = getVTable_Size($CName, 1);
112051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    my $VSize_New = getVTable_Size($CName, 2);
112069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next if($VSize_Old==$VSize_New); # exception: register as removed and added virtual method
112071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(isCopyingClass($Class_Id, 1))
112081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # class has no constructors and v-table will be copied by applications, this may affect all methods
112091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
112101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
112111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Copying_Class";
112121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
112131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
112141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
112151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
112161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
112171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
112181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    else
112191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
112201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Added_Virtual_Method";
112211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isLeafClass($Class_Id, 1)) {
112221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Added_Virtual_Method_At_End_Of_Leaf_Allocable_Class";
112231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
112241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Interface}{$ProblemType}{$tr_name{$AddedVFunc}}}=(
112251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Type_Name"=>$CName,
112261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>get_Signature($AddedVFunc, 2)  );
112271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        $VTableChanged_M{$CName} = 1;
112281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
112291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
112301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
112321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
112331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
11234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName}
11235dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and defined $VirtualTable{2}{$CName})
112361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
11237dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11238dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11239fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11240dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Added<=$VPos_Old and $VPos_Old!=$VPos_New)
112411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11242dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11243dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11244dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11245850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11246850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
112479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11248850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11249850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11250dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11251dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11252dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{"Added_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
11253dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11254dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($AddedVFunc, 2)  );
1125562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
112561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11257ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11258ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
112601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
112611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                # safe
112621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
112641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
112661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($VirtualReplacement{$RemovedVFunc});
112671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($RemovedVFunc eq $Interface
112681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
112691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # This case is for removed virtual methods
112709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko              # implemented in both versions of a library
112711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
112721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$VirtualTable_Model{2}{$CName}}))
112741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # became non-polymorphous class, removed v-table pointer
112751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Last_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
112761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
112771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
112781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $VTableChanged_M{$CName} = 1;
112791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
112801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif($CompleteSignature{1}{$Interface}{"Virt"}
112811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            or $CompleteSignature{1}{$Interface}{"PureVirt"})
11282ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11283dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $VirtualTable{1}{$CName} and defined $VirtualTable{2}{$CName})
11284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11285dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(not defined $VirtualTable{1}{$CName}{$Interface}) {
11286dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        next;
11287dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11288dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_New = -1;
11289dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{2}{$CName}{$Interface})
112901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
11291dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        $VPos_New = $VirtualTable{2}{$CName}{$Interface};
11292dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11293dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    else
11294dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11295dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if($Interface ne $RemovedVFunc) {
112961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
112971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11298dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
11299dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Removed = $VirtualTable{1}{$CName}{$RemovedVFunc};
11300dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $VPos_Old = $VirtualTable{1}{$CName}{$Interface};
11301dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($VPos_Removed<=$VPos_Old and $VPos_Old!=$VPos_New)
11302dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
11303dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        my @Affected = ($Interface, keys(%{$OverriddenMethods{1}{$Interface}}));
11304dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        foreach my $ASymbol (@Affected)
11305dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
11306850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(not $CompleteSignature{1}{$ASymbol}{"PureVirt"})
11307850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
113089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
11309850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
11310850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
11311dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11312dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            my $ProblemType = "Removed_Virtual_Method";
11313dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"}) {
11314dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $ProblemType = "Removed_Pure_Virtual_Method";
11315dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
11316dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $CheckedSymbols{$Level}{$ASymbol} = 1;
11317dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$RemovedVFunc}}}=(
11318dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Type_Name"=>$CName,
11319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                "Target"=>get_Signature($RemovedVFunc, 1)  );
1132062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $VTableChanged_M{$TypeInfo{1}{$CompleteSignature{1}{$ASymbol}{"Class"}}{"Name"}} = 1;
113211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
113271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
113281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # Source-level
113291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $AddedVFunc (keys(%{$AddedInt_Virt{$Level}{$CName}}))
113301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
113311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next if($Interface eq $AddedVFunc);
113321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{2}{$AddedVFunc}{"PureVirt"})
113331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
113341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Added_Pure_Virtual_Method"}{$tr_name{$AddedVFunc}}}=(
113351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
113361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($AddedVFunc, 2)  );
113371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
11338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
113391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $RemovedVFunc (keys(%{$RemovedInt_Virt{$Level}{$CName}}))
11340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
113411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$RemovedVFunc}{"PureVirt"})
11342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
113431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Interface}{"Removed_Pure_Virtual_Method"}{$tr_name{$RemovedVFunc}}}=(
113441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Type_Name"=>$CName,
113451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    "Target"=>get_Signature($RemovedVFunc, 1)  );
11346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byName($$)
11352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Name, $Pair_Type) = @_;
11354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Member_Name=~s/\A[_]+|[_]+\Z//g;
11355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos})
11358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Name = $Pair_Type->{"Memb"}{$MemberPair_Pos}{"name"};
11360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Name=~s/\A[_]+|[_]+\Z//g;
11361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Name eq $Member_Name) {
11362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MemberPair_Pos;
11363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_MemberPair_Pos_byVal($$)
11370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Member_Value, $Pair_Type) = @_;
11372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $MemberPair_Pos (sort {int($a)<=>int($b)} keys(%{$Pair_Type->{"Memb"}}))
11373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Pair_Type->{"Memb"}{$MemberPair_Pos}
11375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Pair_Type->{"Memb"}{$MemberPair_Pos}{"value"} eq $Member_Value) {
11376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $MemberPair_Pos;
11377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
11380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub isRecurType($$$)
11383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach (@{$_[2]})
11385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1138662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if( $_->{"T1"} eq $_[0]
1138762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and $_->{"T2"} eq $_[1] )
11388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
113958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub pushType($$$)
11396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
113978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my %IDs = (
113988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T1" => $_[0],
113998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        "T2" => $_[1]
114001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
114018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    push(@{$_[2]}, \%IDs);
11402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isRenamed($$$$$)
11405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($MemPos, $Type1, $LVersion1, $Type2, $LVersion2) = @_;
11407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Member_Name = $Type1->{"Memb"}{$MemPos}{"name"};
11408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MemberType_Id = $Type1->{"Memb"}{$MemPos}{"type"};
11409f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %MemberType_Pure = get_PureType($MemberType_Id, $TypeInfo{$LVersion1});
11410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not defined $Type2->{"Memb"}{$MemPos}) {
11411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
11412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1141362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $PairType_Id = $Type2->{"Memb"}{$MemPos}{"type"};
11414f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{$LVersion2});
11415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1141662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Pair_Name = $Type2->{"Memb"}{$MemPos}{"name"};
1141762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $MemberPair_Pos_Rev = ($Member_Name eq $Pair_Name)?$MemPos:find_MemberPair_Pos_byName($Pair_Name, $Type1);
11418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($MemberPair_Pos_Rev eq "lost")
11419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1142062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Name"} eq $PairType_Pure{"Name"})
1142162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # base type match
1142262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1142462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LVersion1}{$MemberType_Id}{"Name"} eq $TypeInfo{$LVersion2}{$PairType_Id}{"Name"})
1142562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # exact type match
1142662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1142862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($MemberType_Pure{"Size"} eq $PairType_Pure{"Size"})
1142962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # size match
1143062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1143262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(isReserved($Pair_Name))
1143362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # reserved fields
1143462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $Pair_Name;
11435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
11438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isLastElem($$)
11441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Pos, $TypeRef) = @_;
11443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $TypeRef->{"Memb"}{$Pos}{"name"};
11444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/last|count|max|total/i)
11445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GST_LEVEL_COUNT, GST_RTSP_ELAST
11446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/END|NLIMITS\Z/)
11449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # __RLIMIT_NLIMITS
11450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Name=~/\AN[A-Z](.+)[a-z]+s\Z/
11453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Pos+1==keys(%{$TypeRef->{"Memb"}}))
11454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # NImageFormats, NColorRoles
11455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
11456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub nonComparable($$)
11461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
11462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($T1, $T2) = @_;
11463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N1 = $T1->{"Name"};
11465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $N2 = $T2->{"Name"};
11466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N1=~s/\A(struct|union|enum) //;
11468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $N2=~s/\A(struct|union|enum) //;
11469fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11470fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($N1 ne $N2
11471fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N1)
11472fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not isAnon($N2))
11473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different names
11474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} ne "Pointer"
11475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        or $T2->{"Type"} ne "Pointer")
11476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # compare base types
11477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11479fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($N1!~/\Avoid\s*\*/
11480fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $N2=~/\Avoid\s*\*/)
11481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($T1->{"Type"} ne $T2->{"Type"})
11486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
11487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($T1->{"Type"} eq "Class"
11488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T2->{"Type"} eq "Struct")
11489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "struct"
11490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($T2->{"Type"} eq "Class"
11493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $T1->{"Type"} eq "Struct")
11494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "struct" to "class"
11495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
11496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "class" to "enum"
11499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # "union" to "class"
11500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
11501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
11502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
11505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
11506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11507fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub isOpaque($)
11508fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
11509fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T = $_[0];
11510fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not defined $T->{"Memb"})
11511fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11512fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return 1;
11513fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11514fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 0;
11515fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11516fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11517fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removeVPtr($)
11518fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{ # support for old ABI dumps
11519fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $TPtr = $_[0];
11520fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my @Pos = sort {int($a)<=>int($b)} keys(%{$TPtr->{"Memb"}});
11521fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Pos>=1)
11522fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11523fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Pos (0 .. $#Pos-1)
11524fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11525fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$TPtr->{"Memb"}{$Pos}} = %{$TPtr->{"Memb"}{$Pos+1}};
11526fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11527fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        delete($TPtr->{"Memb"}{$#Pos});
11528fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11529fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
11530fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1153162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub mergeTypes($$$)
11532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1153362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
11534f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Id or not $Type2_Id);
11535f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1153662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id})
11537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already merged
11538f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id};
11539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11540f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
1154162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1154262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
115431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $Type1{"Name"} or not $Type2{"Name"}) {
11544f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
115451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
11546fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11547fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1{"Name"}} = 1;
11548f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
11549f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
11550f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11551fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $CheckedTypes{$Level}{$Type1_Pure{"Name"}} = 1;
11552fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11553f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my %SubProblems = ();
11554f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
11555fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
11556fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
11557fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Type1_Pure{"Type"}=~/Struct|Union/
11558fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $Type2_Pure{"Type"}=~/Struct|Union/)
11559fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11560fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(isOpaque(\%Type2_Pure) and not isOpaque(\%Type1_Pure))
11561fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                %{$SubProblems{"Type_Became_Opaque"}{$Type1_Pure{"Name"}}}=(
11563fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
11564fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11566f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11571177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not $Type1_Pure{"Size"}
11572177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    or not $Type2_Pure{"Size"})
11573850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # including a case when "class Class { ... };" changed to "class Class;"
11574177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not defined $Type1_Pure{"Memb"} or not defined $Type2_Pure{"Memb"}
11575177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or index($Type1_Pure{"Name"}, "<")==-1 or index($Type2_Pure{"Name"}, "<")==-1)
11576177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        { # NOTE: template instances have no size
11577f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return {};
11578177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
11579850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
115808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes))
11581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # skip recursive declarations
11582f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return {};
11583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11584f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if(not $Type1_Pure{"Name"} or not $Type2_Pure{"Name"});
11585f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1_Pure{"Name"}});
11586f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return {} if($SkipTypes{1}{$Type1{"Name"}});
11587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
11588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type1_Pure{"Type"}=~/Class|Struct/ and $Type2_Pure{"Type"}=~/Class|Struct/)
11589fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
11590fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko      # _vptr field added in 3.0
11591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not checkDump(1, "3.0") and checkDump(2, "3.0"))
11592fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11593fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type2_Pure{"Memb"}
11594fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type2_Pure{"Memb"}{0}{"name"} eq "_vptr")
11595fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11596fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type2_Pure{"Memb"}})==1) {
11597fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type2_Pure{"Memb"}{0});
11598fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11599fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11600fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type2_Pure);
11601fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11602fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11603fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(checkDump(1, "3.0") and not checkDump(2, "3.0"))
11605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
11606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(defined $Type1_Pure{"Memb"}
11607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and $Type1_Pure{"Memb"}{0}{"name"} eq "_vptr")
11608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
11609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(keys(%{$Type1_Pure{"Memb"}})==1) {
11610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($Type1_Pure{"Memb"}{0});
11611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
11613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    removeVPtr(\%Type1_Pure);
11614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11615fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
11616fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
11617fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
11618fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1161962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
1162062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
11621fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
11622dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $UseOldDumps and %Typedef_1 and %Typedef_2
11623dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef"
11624dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    and $Typedef_1{"Name"} eq $Typedef_2{"Name"})
11625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
11626f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_1 = get_OneStep_BaseType($Typedef_1{"Tid"}, $TypeInfo{1});
11627f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my %Base_2 = get_OneStep_BaseType($Typedef_2{"Tid"}, $TypeInfo{2});
11628850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Base_1{"Name"} ne $Base_2{"Name"})
11629850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
11630850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if(differentDumps("G")
11631850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            or differentDumps("V"))
11632850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # different GCC versions or different dumps
11633850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"} = uncover_typedefs($Base_1{"Name"}, 1);
11634850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"} = uncover_typedefs($Base_2{"Name"}, 2);
11635850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # std::__va_list and __va_list
11636850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_1{"Name"}=~s/\A(\w+::)+//;
11637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $Base_2{"Name"}=~s/\A(\w+::)+//;
116389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_1{"Name"} = formatName($Base_1{"Name"}, "T");
116399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Base_2{"Name"} = formatName($Base_2{"Name"}, "T");
11640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
11641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Base_1{"Name"}!~/anon\-/ and $Base_2{"Name"}!~/anon\-/
11643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Base_1{"Name"} ne $Base_2{"Name"})
11644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
116451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
116461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Type1{"Size"} ne $Type2{"Size"})
11647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"DataType_Size"}{$Typedef_1{"Name"}}}=(
11649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Typedef_1{"Name"},
11650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Typedef_1{"Name"},
11651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
11652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE  );
11653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
116548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base1_Pure = get_PureType($Base_1{"Tid"}, $TypeInfo{1});
116558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my %Base2_Pure = get_PureType($Base_2{"Tid"}, $TypeInfo{2});
11656fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(tNameLock($Base_1{"Tid"}, $Base_2{"Tid"}))
116578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
11658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(diffTypes($Base1_Pure{"Tid"}, $Base2_Pure{"Tid"}, $Level))
11659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType_Format"}{$Typedef_1{"Name"}}}=(
11661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
11666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
11667fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
11668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Typedef_BaseType"}{$Typedef_1{"Name"}}}=(
11669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Typedef_1{"Name"},
11670fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Typedef_1{"Name"},
11671fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Base_1{"Name"},
11672fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$Base_2{"Name"}  );
11673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
116748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
11675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(nonComparable(\%Type1_Pure, \%Type2_Pure))
11678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types (reported in detectTypeChange(...))
1167974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT1 = $Type1_Pure{"Type"};
1168074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $TT2 = $Type2_Pure{"Type"};
1168174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1168274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($TT1 ne $TT2
1168374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        and $TT1!~/Intrinsic|Pointer|Ref|Typedef/)
11684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different type of the type
1168574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short1 = $Type1_Pure{"Name"};
1168674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Short2 = $Type2_Pure{"Name"};
1168774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1168874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short1=~s/\A\Q$TT1\E //ig;
1168974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $Short2=~s/\A\Q$TT2\E //ig;
1169074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1169174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($Short1 eq $Short2)
1169274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1169374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                %{$SubProblems{"DataType_Type"}{$Type1_Pure{"Name"}}}=(
1169474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Target"=>$Type1_Pure{"Name"},
1169574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
1169674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Old_Value"=>lc($Type1_Pure{"Type"}),
1169774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>lc($Type2_Pure{"Type"})  );
1169874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
11699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11700f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
11701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
117028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($Type1_Pure{"Tid"}, $Type2_Pure{"Tid"}, \@RecurTypes);
11703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(($Type1_Pure{"Name"} eq $Type2_Pure{"Name"}
11704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or (isAnon($Type1_Pure{"Name"}) and isAnon($Type2_Pure{"Name"})))
11705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking size
117071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
117081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ProblemKind = "DataType_Size";
11711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Class"
117121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and keys(%{$ClassMethods{$Level}{1}{$Type1_Pure{"Name"}}}))
11713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isCopyingClass($Type1_Pure{"Tid"}, 1)) {
11715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemKind = "Size_Of_Copying_Class";
11716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif($AllocableClass{1}{$Type1_Pure{"Name"}})
11718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(int($Type2_Pure{"Size"})>int($Type1_Pure{"Size"})) {
11720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemKind = "Size_Of_Allocable_Class_Increased";
11721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11722fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    else
11723fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
11724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # descreased size of allocable class
11725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        # it has no special effects
11726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            %{$SubProblems{$ProblemKind}{$Type1_Pure{"Name"}}}=(
11730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Type1_Pure{"Name"},
11731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Type_Name"=>$Type1_Pure{"Name"},
11732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Size"=>$Type1_Pure{"Size"}*$BYTE_SIZE,
11733f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "New_Size"=>$Type2_Pure{"Size"}*$BYTE_SIZE);
11734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11736fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Type1_Pure{"BaseType"}
11737fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and defined $Type2_Pure{"BaseType"})
117380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # checking base types
11739f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Sub_SubProblems = mergeTypes($Type1_Pure{"BaseType"}, $Type2_Pure{"BaseType"}, $Level);
11740f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
11741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11742f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}})) {
11743f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $SubProblems{$Sub_SubProblemType}{$Sub_SubLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
11744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%AddedField, %RemovedField, %RenamedField, %RenamedField_Rev, %RelatedField, %RelatedField_Rev) = ();
11748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosA = map {$Type1_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type1_Pure{"Memb"}});
11749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %NameToPosB = map {$Type2_Pure{"Memb"}{$_}{"name"}=>$_} keys(%{$Type2_Pure{"Memb"}});
11750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect removed and renamed fields
11752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isUnnamed($Member_Name))
11760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # support for old-version dumps
11761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1176262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(not checkDump(2, "2.1")) {
11763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $RenamedTo = isRenamed($Member_Pos, \%Type1_Pure, 1, \%Type2_Pure, 2))
11767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11768082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField{$Member_Pos} = $RenamedTo;
11769082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11773082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
11779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
11780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MemberPair_Pos = find_MemberPair_Pos_byVal($Member_Value1, \%Type2_Pure);
11781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberPair_Pos ne "lost")
11782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # renamed
11783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $RenamedTo = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"name"};
11784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $MemberPair_Pos_Rev = find_MemberPair_Pos_byName($RenamedTo, \%Type1_Pure);
11785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberPair_Pos_Rev eq "lost")
11786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
11787082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField{$Member_Pos} = $RenamedTo;
11788082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RenamedField_Rev{$NameToPosB{$RenamedTo}} = $Member_Name;
11789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else {
11791082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                        $RemovedField{$Member_Pos} = 1;
11792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed
11796082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                    $RemovedField{$Member_Pos} = 1;
11797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
11801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # related
11802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField{$Member_Pos} = $MemberPair_Pos;
11803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $RelatedField_Rev{$MemberPair_Pos} = $Member_Pos;
11804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect added fields
11808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey 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);
11811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($MemberPair_Pos eq "lost")
11812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(isUnnamed($Member_Name))
11814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # support for old-version dumps
118151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            # unnamed fields have been introduced in the ACC 1.23 (dump 2.1 format)
1181662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not checkDump(1, "2.1")) {
11817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union|Enum)\Z/)
11821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $RenamedField_Rev{$Member_Pos})
11823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added
11824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $AddedField{$Member_Pos}=1;
11825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # detect moved fields
11831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (%RelPos, %RelPosName, %AbsPos) = ();
11832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Pos = 0;
11833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
11834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 1st version
11835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $RemovedField{$Member_Pos})
11838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # old type without removed fields
11839082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{1}{$Member_Name} = $Pos;
11840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{1}{$Pos} = $Member_Name;
11841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{1}{$Pos++} = $Member_Pos;
11842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Pos = 0;
11845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
11846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative positions in 2nd version
11847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
11848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(not $Member_Name);
11849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not $AddedField{$Member_Pos})
11850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # new type without added fields
11851082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko                $RelPos{2}{$Member_Name} = $Pos;
11852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $RelPosName{2}{$Pos} = $Member_Name;
11853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AbsPos{2}{$Pos++} = $Member_Pos;
11854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Member_Name (keys(%{$RelPos{1}}))
11857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
11858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos1 = $RelPos{1}{$Member_Name};
11859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $AbsPos1 = $NameToPosA{$Member_Name};
11860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Member_Name2 = $Member_Name;
11861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $RenamedTo = $RenamedField{$AbsPos1})
11862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # renamed
11863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Member_Name2 = $RenamedTo;
11864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $RPos2 = $RelPos{2}{$Member_Name2};
11866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RPos2 ne "" and $RPos1 ne $RPos2)
11867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different relative positions
11868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $AbsPos2 = $NameToPosB{$Member_Name2};
11869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($AbsPos1 ne $AbsPos2)
11870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # different absolute positions
11871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Moved_Field";
11872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(not isPublic(\%Type1_Pure, $AbsPos1))
11873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # may change layout and size of type
118741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Source") {
118751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            next;
118761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
11877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Moved_Private_Field";
11878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
118791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Binary"
118801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
1188262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize1 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$AbsPos1}{"type"}}{"Size"};
11883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $MovedAbsPos = $AbsPos{1}{$RPos2};
1188462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $MemSize2 = $TypeInfo{1}{$Type1_Pure{"Memb"}{$MovedAbsPos}{"type"}}{"Size"};
11885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($MemSize1 ne $MemSize2) {
11886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Size";
11887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Moved_Private_Field") {
11890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
11891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
11893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$RPos1,
11896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RPos2 );
11897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
11901ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type1_Pure{"Memb"}}))
119021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check older fields, public and private
11903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type1_Pure{"Memb"}{$Member_Pos}{"name"};
11904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
11905082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
11906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $RenamedTo = $RenamedField{$Member_Pos})
11907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # renamed
119088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(defined $Constants{2}{$Member_Name})
119098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
119108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Constants{2}{$Member_Name}{"Value"} eq $RenamedTo)
119118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # define OLD NEW
119128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next; # Safe
119138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
119148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
119158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
11916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
11917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(isPublic(\%Type1_Pure, $Member_Pos))
11919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Renamed_Field"}{$Member_Name}}=(
11921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
11922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
11923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
11924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
11925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(isReserved($Member_Name))
119279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
119289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    %{$SubProblems{"Used_Reserved_Field"}{$Member_Name}}=(
119299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Target"=>$Member_Name,
119309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
119319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "Old_Value"=>$Member_Name,
119329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        "New_Value"=>$RenamedTo  );
119339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
11934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Name"}{$Type1_Pure{"Memb"}{$Member_Pos}{"value"}}}=(
11938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Type1_Pure{"Memb"}{$Member_Pos}{"value"},
11939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
11940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name,
11941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$RenamedTo  );
11942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
11944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($RemovedField{$Member_Pos})
11945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # removed
11946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
11947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Removed_Field";
11949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos)
119501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
119511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
119521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
119531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
119541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
11955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Removed_Private_Field";
11956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
119571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
11958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
11959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
11961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected fields
11962fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
11963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
11964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
11965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
11966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # affected size
11969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
11970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
11971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Removed_Private_Field") {
11973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
11974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
11976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1197774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"}  );
11978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
11980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
119811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
119821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
11983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field_And_Size"}{$Member_Name}}=(
11985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1198674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
11989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
11990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Removed_Union_Field"}{$Member_Name}}=(
11991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1199274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"}  );
11993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
11994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
11995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type1_Pure{"Type"} eq "Enum")
11996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
11997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Enum_Member_Removed"}{$Member_Name}}=(
11998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
11999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"},
12000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Member_Name  );
12001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
12004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # changed
12005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $MemberPair_Pos = $RelatedField{$Member_Pos};
12006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type1_Pure{"Type"} eq "Enum")
12007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value1 = $Type1_Pure{"Memb"}{$Member_Pos}{"value"};
12009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value1 eq "");
12010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"value"};
12011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value2 eq "");
12012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Member_Value1 ne $Member_Value2)
12013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType = "Enum_Member_Value";
12015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(isLastElem($Member_Pos, \%Type1_Pure)) {
12016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType = "Enum_Last_Member_Value";
12017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12018fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($SkipConstants{1}{$Member_Name}) {
12019fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemType = "Enum_Private_Member_Value";
12020fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
12023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"},
12024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Member_Value1,
12025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Member_Value2  );
12026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"}=~/\A(Struct|Class|Union)\Z/)
12029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access1 = $Type1_Pure{"Memb"}{$Member_Pos}{"access"};
12031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Access2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"access"};
12032fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Access1 ne "private"
12034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "private")
12035fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12036fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Private"}{$Member_Name}}=(
12037fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Access1 ne "protected"
12041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access1 ne "private"
12042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and $Access2 eq "protected")
12043fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12044fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Field_Became_Protected"}{$Member_Name}}=(
12045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$Member_Name,
12046fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12047fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType1_Id = $Type1_Pure{"Memb"}{$Member_Pos}{"type"};
12050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MemberType2_Id = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"type"};
1205162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV1 = $TypeInfo{1}{$MemberType1_Id}{"Size"}*$BYTE_SIZE;
12052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize1 = $Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}) {
12053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV1 = $BSize1;
12054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1205562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $SizeV2 = $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE;
12056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(my $BSize2 = $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}) {
12057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SizeV2 = $BSize2;
12058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1205962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType1_Name = $TypeInfo{1}{$MemberType1_Id}{"Name"};
1206062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $MemberType2_Name = $TypeInfo{2}{$MemberType2_Id}{"Name"};
120611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
120621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $SizeV1 ne $SizeV2)
12063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($MemberType1_Name eq $MemberType2_Name or (isAnon($MemberType1_Name) and isAnon($MemberType2_Name))
12065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or ($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"} and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"}))
12066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # field size change (including anon-structures and unions)
12067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - same types
12068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - unnamed types
12069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                      # - bitfields
12070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Field_Size";
12071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name))
12073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # should not be accessed by applications, goes to "Low Severity"
12074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                          # example: "abidata" members in GStreamer types
12075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12080fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12082fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType eq "Private_Field_Size")
12092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # private field size with no effect
12093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "";
12094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1209546bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        if($ProblemType eq "Field_Size")
1209646bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        {
1209746bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            if($Type1_Pure{"Type"}=~/Union|Struct/ and $SizeV1<$SizeV2)
1209846bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            { # Low severity
1209946bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                                $ProblemType = "Struct_Field_Size_Increased";
1210046bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                            }
1210146bef51336341bdb98ccb48ef77e476d78e1ec01Andrey Ponomarenko                        }
12102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($ProblemType)
12103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # register a problem
12104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            %{$SubProblems{$ProblemType}{$Member_Name}}=(
12105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Target"=>$Member_Name,
12106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Type_Name"=>$Type1_Pure{"Name"},
12107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "Old_Size"=>$SizeV1,
12108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                "New_Size"=>$SizeV2);
12109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type1_Pure{"Memb"}{$Member_Pos}{"bitfield"}
12113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or $Type2_Pure{"Memb"}{$MemberPair_Pos}{"bitfield"})
12114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check bitfield type changes
12115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1211762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(checkDump(1, "2.13") and checkDump(2, "2.13"))
121180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
121190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not $Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
121200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
121210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
121220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Mutable"}{$Member_Name}}=(
121230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1212474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
121250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    elsif($Type1_Pure{"Memb"}{$Member_Pos}{"mutable"}
121270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    and not $Type2_Pure{"Memb"}{$MemberPair_Pos}{"mutable"})
121280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
12129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$SubProblems{"Field_Became_Non_Mutable"}{$Member_Name}}=(
121300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>$Member_Name,
1213174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "Type_Name"=>$Type1_Pure{"Name"});
121320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
121330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
12134f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my %Sub_SubChanges = detectTypeChange($MemberType1_Id, $MemberType2_Id, "Field", $Level);
12135f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12137f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12138f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12139fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12140fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    # quals
12141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type"
12142fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_And_Size"
12143fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $ProblemType eq "Field_Type_Format")
12144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1214562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(checkDump(1, "2.6") and checkDump(2, "2.6"))
12146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12147fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(addedQual($Old_Value, $New_Value, "volatile")) {
12148f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
121490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12150fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            elsif(removedQual($Old_Value, $New_Value, "volatile")) {
12151f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Volatile"}} = %{$Sub_SubChanges{$ProblemType}};
12152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
121540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if(my $RA = addedQual($Old_Value, $New_Value, "const"))
121550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RA==2) {
12157f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Added_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12160f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
121630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
121640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
121650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            if($RR==2) {
12166f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Removed_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            else {
12169f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                %{$Sub_SubChanges{"Field_Became_Non_Const"}} = %{$Sub_SubChanges{$ProblemType}};
121700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
12171fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
12172fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
12173fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
12174fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12175fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Source")
12176fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
12177f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $ProblemType (keys(%Sub_SubChanges))
12178fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
12179f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Old_Value = $Sub_SubChanges{$ProblemType}{"Old_Value"};
12180f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $New_Value = $Sub_SubChanges{$ProblemType}{"New_Value"};
12181fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12182fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($ProblemType eq "Field_Type")
12183fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
12184fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
12185f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                delete($Sub_SubChanges{$ProblemType});
121860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            }
121870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
12188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12190fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
12191f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $ProblemType (keys(%Sub_SubChanges))
12192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemType_Init = $ProblemType;
12194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Field_Type_And_Size")
121951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # Binary
12196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Private_".$ProblemType;
12199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(not isMemPadded($Member_Pos, $TypeInfo{2}{$MemberType2_Id}{"Size"}*$BYTE_SIZE, \%Type1_Pure, \%RemovedField, $TypeInfo{1}, getArch(1), $WORD_SIZE{1}))
12201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # check an effect
12202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Type2_Pure{"Type"} ne "Union"
12203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            and my $MNum = isAccessible(\%Type1_Pure, \%RemovedField, $Member_Pos+1, -1))
12204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            { # public fields after the current
12205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                { # changed offset
12207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemType .= "_And_Layout";
12208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
12209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType .= "_And_Type_Size";
12212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
12216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if(not isPublic(\%Type1_Pure, $Member_Pos)
12218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        or isUnnamed($Member_Name)) {
12219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            next;
12220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($ProblemType eq "Private_Field_Type_And_Size")
12223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # private field change with no effect
12224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
12225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{$ProblemType}{$Member_Name}}=(
12227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1222874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
1222974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
12230f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Attr (keys(%{$Sub_SubChanges{$ProblemType_Init}}))
12231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # other properties
12232f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $SubProblems{$ProblemType}{$Member_Name}{$Attr} = $Sub_SubChanges{$ProblemType_Init}{$Attr};
12233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type1_Pure, $Member_Pos))
12236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # do NOT check internal type changes
12237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($MemberType1_Id and $MemberType2_Id)
12240f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # checking member type changes
12241f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Sub_SubProblems = mergeTypes($MemberType1_Id, $MemberType2_Id, $Level);
12242f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12243f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my %DupProblems = ();
12244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12245f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Sub_SubProblemType (keys(%{$Sub_SubProblems}))
12246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
12247f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Sub_SubLocation (keys(%{$Sub_SubProblems->{$Sub_SubProblemType}}))
12248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
12249f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12250f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12251f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                if(defined $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}}) {
12252f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    next;
12253f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                }
12254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12255f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12256f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $NewLocation = ($Sub_SubLocation)?$Member_Name."->".$Sub_SubLocation:$Member_Name;
12257f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            $SubProblems{$Sub_SubProblemType}{$NewLocation} = $Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation};
12258f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12259f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            if(not defined $AllAffected)
12260f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            {
12261f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $DupProblems{$Sub_SubProblems->{$Sub_SubProblemType}{$Sub_SubLocation}} = 1;
12262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
12263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12265f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12266f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %DupProblems = ();
12267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Member_Pos (sort {int($a) <=> int($b)} keys(%{$Type2_Pure{"Memb"}}))
12272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added members, public and private
12273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Member_Name = $Type2_Pure{"Memb"}{$Member_Pos}{"name"};
12274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Member_Name);
12275082b4d0f5f7ff57bbb56a8e965b3ecf3182179b3Andrey Ponomarenko        next if($Member_Name eq "_vptr");
12276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AddedField{$Member_Pos})
12277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # added
12278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2_Pure{"Type"}=~/\A(Struct|Class)\Z/)
12279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemType = "Added_Field";
12281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not isPublic(\%Type2_Pure, $Member_Pos)
122821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                or isUnnamed($Member_Name))
122831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
122841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source") {
122851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
122861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemType = "Added_Private_Field";
12288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
122891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
12290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not isMemPadded($Member_Pos, -1, \%Type2_Pure, \%AddedField, $TypeInfo{2}, getArch(2), $WORD_SIZE{2}))
12291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(my $MNum = isAccessible(\%Type2_Pure, \%AddedField, $Member_Pos, -1))
12293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # public fields after the current
12294fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey 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}))
12295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        { # changed offset
12296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType .= "_And_Layout";
12297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
12298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Size"} ne $Type2_Pure{"Size"}) {
12300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemType .= "_And_Size";
12301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
12302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ProblemType eq "Added_Private_Field")
12304ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # skip added private fields
12305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
12306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{$ProblemType}{$Member_Name}}=(
12308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
1230974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "Type_Name"=>$Type1_Pure{"Name"});
12310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Union")
12312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
123131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
123141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and $Type1_Pure{"Size"} ne $Type2_Pure{"Size"})
12315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field_And_Size"}{$Member_Name}}=(
12317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1231874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
12321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
12322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$SubProblems{"Added_Union_Field"}{$Member_Name}}=(
12323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Target"=>$Member_Name,
1232474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Type_Name"=>$Type1_Pure{"Name"});
12325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Type2_Pure{"Type"} eq "Enum")
12328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
12329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Member_Value = $Type2_Pure{"Memb"}{$Member_Pos}{"value"};
12330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if($Member_Value eq "");
12331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$SubProblems{"Added_Enum_Member"}{$Member_Name}}=(
12332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Target"=>$Member_Name,
12333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Type_Name"=>$Type2_Pure{"Name"},
1233474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    "New_Value"=>$Member_Value);
12335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12338f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
12339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurTypes);
12340f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return ($Cache{"mergeTypes"}{$Level}{$Type1_Id}{$Type2_Id} = \%SubProblems);
12341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isUnnamed($) {
12344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0]=~/\Aunnamed\d+\Z/;
12345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1234774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_ShortClass($$)
12348dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko{
12349dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
1235074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TypeName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
1235174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TypeInfo{$LibVersion}{$TypeId}{"Type"}!~/Intrinsic|Class|Struct|Union|Enum/) {
1235274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName = uncover_typedefs($TypeName, $LibVersion);
1235374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1235462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $NameSpace = $TypeInfo{$LibVersion}{$TypeId}{"NameSpace"}) {
1235574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $TypeName=~s/\A(struct |)\Q$NameSpace\E\:\://g;
12356dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
12357dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return $TypeName;
12358dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko}
12359dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko
1236062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub goToFirst($$$)
12361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1236262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion, $Type_Type) = @_;
123631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return () if(not $TypeId);
1236462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}) {
1236562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type}};
12366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1236762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1236862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type{"Type"});
12370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} ne $Type_Type)
12371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return () if(not $Type{"BaseType"});
12373fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = goToFirst($Type{"BaseType"}, $LibVersion, $Type_Type);
12374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1237562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"goToFirst"}{$TypeId}{$LibVersion}{$Type_Type} = \%Type;
12376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkomy %TypeSpecAttributes = (
12380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Const" => 1,
12381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Volatile" => 1,
12382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "ConstVolatile" => 1,
12383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Restrict" => 1,
12384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Typedef" => 1
12385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
12386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1238762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PureType($$)
12388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12389f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12390f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12391f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12392f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12394f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(defined $Cache{"get_PureType"}{$TypeId}{$Info}) {
12395f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %{$Cache{"get_PureType"}{$TypeId}{$Info}};
12396f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12397f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TypeSpecAttributes{$Type{"Type"}}) {
12400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        %Type = get_PureType($Type{"BaseType"}, $Info);
12401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12402f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    $Cache{"get_PureType"}{$TypeId}{$Info} = \%Type;
12403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1240662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_PLevel($$)
12407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1240862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $TypeId);
1241062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_PLevel"}{$TypeId}{$LibVersion}) {
1241162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"get_PLevel"}{$TypeId}{$LibVersion};
12412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1241362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $TypeInfo{$LibVersion}{$TypeId});
1241462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12415fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return 1 if($Type{"Type"}=~/FuncPtr|FieldPtr/);
12416fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $PLevel = 0;
12417fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Type{"Type"} =~/Pointer|Ref|FuncPtr|FieldPtr/) {
12418fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $PLevel += 1;
12419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12420fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel if(not $Type{"BaseType"});
12421fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $PLevel += get_PLevel($Type{"BaseType"}, $LibVersion);
12422fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $Cache{"get_PLevel"}{$TypeId}{$LibVersion} = $PLevel;
12423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $PLevel;
12424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1242662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseType($$)
12427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1242862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $TypeId);
1243062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"get_BaseType"}{$TypeId}{$LibVersion}) {
1243162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return %{$Cache{"get_BaseType"}{$TypeId}{$LibVersion}};
12432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1243362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1243462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    %Type = get_BaseType($Type{"BaseType"}, $LibVersion);
1243762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    $Cache{"get_BaseType"}{$TypeId}{$LibVersion} = \%Type;
12438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %Type;
12439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1244162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_BaseTypeQual($$)
12442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1244362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $TypeId);
1244562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return "" if(not $TypeInfo{$LibVersion}{$TypeId});
1244662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type = %{$TypeInfo{$LibVersion}{$TypeId}};
12447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return "" if(not $Type{"BaseType"});
12448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Qual = "";
12449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type{"Type"} eq "Pointer") {
12450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "*";
12451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Ref") {
12453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "&";
12454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "ConstVolatile") {
12456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= "const volatile";
12457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type{"Type"} eq "Const"
12459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Volatile"
12460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type{"Type"} eq "Restrict") {
12461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Qual .= lc($Type{"Type"});
12462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $BQual = get_BaseTypeQual($Type{"BaseType"}, $LibVersion);
12464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $BQual.$Qual;
12465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1246762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_OneStep_BaseType($$)
12468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12469f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my ($TypeId, $Info) = @_;
12470f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if(not $TypeId or not $Info
12471f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    or not $Info->{$TypeId}) {
12472f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return ();
12473f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type = %{$Info->{$TypeId}};
12475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return %Type if(not $Type{"BaseType"});
12476fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(my $BTid = $Type{"BaseType"})
12477f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
12478f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($Info->{$BTid}) {
12479f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return %{$Info->{$BTid}};
12480f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12481f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        else { # something is going wrong
12482f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            return ();
12483f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
12484f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12485f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    else {
12486f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return %Type;
12487f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
12488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1249062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub get_Type($$)
12491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1249262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($TypeId, $LibVersion) = @_;
12493dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    return () if(not $TypeId);
1249462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return () if(not $TypeInfo{$LibVersion}{$TypeId});
1249562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return %{$TypeInfo{$LibVersion}{$TypeId}};
12496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12498989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenkosub isPrivateData($)
124990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{ # non-public global data
12500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
12501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Symbol=~/\A(_ZGV|_ZTI|_ZTS|_ZTT|_ZTV|_ZTC|_ZThn|_ZTv0_n)/);
12502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1250401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub isInLineInst($$$) {
1250501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return (isTemplateInstance(@_) and not isTemplateSpec(@_));
1250601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1250701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1250801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub isTemplateInstance($$$)
12509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1251001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Symbol, $SInfo, $LibVersion) = @_;
1251162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckObjectsOnly)
1251262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1251362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Symbol!~/\A(_Z|\?)/) {
1251462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return 0;
1251562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1251662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Signature = $tr_name{$Symbol})
1251762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1251862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(index($Signature,">")==-1) {
1251962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return 0;
1252062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1252162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1252262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1252301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(index($ShortName,"<")!=-1
1252401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                and index($ShortName,">")!=-1) {
1252562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return 1;
1252662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1252762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1252862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1252962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1253062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
1253162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1253201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $ClassId = $SInfo->{"Class"})
1253362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1253462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassName = $TypeInfo{$LibVersion}{$ClassId}{"Name"})
1253562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1253662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(index($ClassName,"<")!=-1) {
1253762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return 1;
1253862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1253962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1254062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1254101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $ShortName = $SInfo->{"ShortName"})
1254262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1254301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(index($ShortName,"<")!=-1
1254401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and index($ShortName,">")!=-1) {
1254562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return 1;
1254662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1254762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1254862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1254962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0;
12550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1255201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub isTemplateSpec($$$)
12553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1255401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($Symbol, $SInfo, $LibVersion) = @_;
1255501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $ClassId = $SInfo->{"Class"})
12556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1255762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$ClassId}{"Spec"})
12558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class specialization
12559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1256101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        elsif($SInfo->{"Spec"})
12562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # method specialization
12563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
12564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
12567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
125691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub symbolFilter($$$$)
12570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # some special cases when the symbol cannot be imported
125711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $LibVersion, $Type, $Level) = @_;
12572989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(isPrivateData($Symbol))
12573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # non-public global data
12574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
12575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckObjectsOnly) {
12577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0 if($Symbol=~/\A(_init|_fini)\Z/);
12578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1257962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($CheckHeadersOnly and not checkDump($LibVersion, "2.7"))
12580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps in --headers-only mode
12581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Pos (keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
12582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Pid = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$Pos}{"type"})
12584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1258562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType = $TypeInfo{$LibVersion}{$Pid}{"Type"};
12586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $PType or $PType eq "Unknown") {
12587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12592850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Type=~/Affected/)
12593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"};
12595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipSymbols{$LibVersion}{$Symbol})
12596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols to ignore
12597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NameSpace = $CompleteSignature{$LibVersion}{$Symbol}{"NameSpace"};
12600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $NameSpace and $ClassId)
12601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # class methods have no "NameSpace" attribute
1260262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $NameSpace = $TypeInfo{$LibVersion}{$ClassId}{"NameSpace"};
12603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($NameSpace)
12605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined namespaces to ignore
12606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SkipNameSpaces{$LibVersion}{$NameSpace}) {
12607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
12608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NS (keys(%{$SkipNameSpaces{$LibVersion}}))
12610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # nested namespaces
12611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($NameSpace=~/\A\Q$NS\E(\:\:|\Z)/) {
12612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Header = $CompleteSignature{$LibVersion}{$Symbol}{"Header"})
12617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1261862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Skip = skipHeader($Header, $LibVersion))
12619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # --skip-headers or <skip_headers> (not <skip_including>)
12620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Skip==1) {
12621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    return 0;
12622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SymbolsListPath and not $SymbolsList{$Symbol})
12626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols
12627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12629fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SkipSymbolsListPath and $SkipSymbolsList{$Symbol})
12630fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # user defined symbols
12631fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
12632fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
12633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($AppPath and not $SymbolsList_App{$Symbol})
12634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # user defined symbols (in application)
12635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
12636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12637850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not selectSymbol($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $Level, $LibVersion))
12638850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # non-target symbols
12639850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 0;
12640850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
126411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary")
12642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1264362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CheckObjectsOnly)
1264462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1264501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(isTemplateInstance($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $LibVersion)) {
1264662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    return 0;
1264762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1264862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1264962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
126501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1265162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($CompleteSignature{$LibVersion}{$Symbol}{"InLine"}
1265201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                or isInLineInst($Symbol, $CompleteSignature{$LibVersion}{$Symbol}, $LibVersion))
1265362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1265462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($ClassId and $CompleteSignature{$LibVersion}{$Symbol}{"Virt"})
1265562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # inline virtual methods
1265662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($Type=~/InlineVirt/) {
1265762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            return 1;
1265862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        }
1265962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $Allocable = (not isCopyingClass($ClassId, $LibVersion));
1266062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(not $Allocable)
1266162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        { # check bases
1266262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            foreach my $DCId (get_sub_classes($ClassId, $LibVersion, 1))
1266362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            {
1266462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                if(not isCopyingClass($DCId, $LibVersion))
1266562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                { # exists a derived class without default c-tor
1266662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    $Allocable=1;
1266762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    last;
1266862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                }
126691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
12670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1267162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(not $Allocable) {
1267262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            return 0;
1267362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        }
12674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1267562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
1267662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # inline non-virtual methods
126771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        return 0;
126781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
12679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
12684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub mergeImpl()
12687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $DiffCmd = get_CmdPath("diff");
12689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DiffCmd) {
12690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"diff\"");
12691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$Symbol_Library{1}}))
12693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # implementation changes
12694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Interface}{"Private"});
12695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Interface}{"Header"} and not $CheckObjectsOnly);
12696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Symbol_Library{2}{$Interface} and not $Symbol_Library{2}{$SymVer{2}{$Interface}});
12697850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Interface, 1, "Affected", "Binary")) {
12698850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            next;
12699850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
127001693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Impl1 = canonifyImpl($Interface_Impl{1}{$Interface});
12701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Impl1);
127021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Impl2 = canonifyImpl($Interface_Impl{2}{$Interface});
12703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Impl2);
12704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Impl1 ne $Impl2)
12705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            writeFile("$TMP_DIR/impl1", $Impl1);
12707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            writeFile("$TMP_DIR/impl2", $Impl2);
12708a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            my $Diff = `$DiffCmd -rNau \"$TMP_DIR/impl1\" \"$TMP_DIR/impl2\"`;
12709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Diff=~s/(---|\+\+\+).+\n//g;
12710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Diff=~s/[ ]{3,}/ /g;
12711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Diff=~s/\n\@\@/\n \n\@\@/g;
12712a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            unlink("$TMP_DIR/impl1");
12713a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            unlink("$TMP_DIR/impl2");
127148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Impl{$Interface}}=(
12715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Diff" => get_CodeView($Diff)  );
12716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12718850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
12719850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
12720850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %Interface_Impl = ();
12721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
127231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub canonifyImpl($)
12724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FuncBody=  $_[0];
12726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $FuncBody);
12727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/0x[a-f\d]+/0x?/g;# addr
12728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/((\A|\n)[a-z]+[\t ]+)[a-f\d]+([^x]|\Z)/$1?$3/g;# call, jump
12729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/# [a-f\d]+ /# ? /g;# call, jump
12730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/%([a-z]+[a-f\d]*)/\%reg/g;# registers
12731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($FuncBody=~s/\nnop[ \t]*(\n|\Z)/$1/g){};# empty op
12732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/<.+?\.cpp.+?>/<name.cpp>/g;
12733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/(\A|\n)[a-f\d]+ </$1? </g;# 5e74 <_ZN...
12734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/\.L\d+/.L/g;
12735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/#(-?)\d+/#$1?/g;# r3, [r3, #120]
12736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $FuncBody=~s/[\n]{2,}/\n/g;
12737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $FuncBody;
12738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_CodeView($)
12741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Code = $_[0];
12743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $View = "";
12744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Line (split(/\n/, $Code))
12745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~s/\A(\+|-)/$1 /g)
12747dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # bold line
12748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $View .= "<tr><td><b>".htmlSpecChars($Line)."</b></td></tr>\n";
12749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $View .= "<tr><td>".htmlSpecChars($Line)."</td></tr>\n";
12752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<table class='code_view'>$View</table>\n";
12755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
12757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getImplementations($$)
12758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
12759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
12760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
12761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos")
12762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $OtoolCmd = get_CmdPath("otool");
12764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $OtoolCmd) {
12765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"otool\"");
12766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CurInterface = "";
12768a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        foreach my $Line (split(/\n/, `$OtoolCmd -tv \"$Path\" 2>\"$TMP_DIR/null\"`))
12769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~/\A\s*_(\w+)\s*:/i) {
12771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CurInterface = $1;
12772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Line=~/\A\s*[\da-z]+\s+(.+?)\Z/i) {
1277462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Interface_Impl{$LibVersion}{$CurInterface} .= $1."\n";
12775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
12779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ObjdumpCmd = get_CmdPath("objdump");
12781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ObjdumpCmd) {
12782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"objdump\"");
12783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $CurInterface = "";
12785a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        foreach my $Line (split(/\n/, `$ObjdumpCmd -d \"$Path\" 2>\"$TMP_DIR/null\"`))
12786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
12787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~/\A[\da-z]+\s+<(\w+)>/i) {
12788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CurInterface = $1;
12789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
12791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # x86:    51fa:(\t)89 e5               (\t)mov    %esp,%ebp
12792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # arm:    5020:(\t)e24cb004(\t)sub(\t)fp, ip, #4(\t); 0x4
12793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A\s*[a-f\d]+:\s+([a-f\d]+\s+)+([a-z]+\s+.*?)\s*(;.*|)\Z/i) {
1279462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Interface_Impl{$LibVersion}{$CurInterface} .= $2."\n";
12795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
12796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
128011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded($)
12802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{2}}))
12805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 1, "+Deps"))
12807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find a new symbol
12808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the old-version library
12809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # So, it's not a new symbol
12810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{2}{$Symbol}
1281362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $AddedInt{$Level}{$Symbol} = 1;
12817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
128201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved($)
12821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (keys(%{$Symbol_Library{1}}))
12824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
12825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckObjectsOnly) {
128261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CheckedSymbols{"Binary"}{$Symbol} = 1;
12827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(link_symbol($Symbol, 2, "+Deps"))
12829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # linker can find an old symbol
12830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # in the new-version library
12831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $VSym = $SymVer{1}{$Symbol}
1283462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and index($Symbol,"\@")==-1) {
12835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RemovedInt{$Level}{$Symbol} = 1;
12838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
128411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeLibs($)
12842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
128441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
12845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
12846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
12847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $CompleteSignature{2}{$Symbol}{"Header"} and not $CheckObjectsOnly);
12848c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected + InlineVirt", $Level));
128491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
12850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
128511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
12852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
12853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
12854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $CompleteSignature{1}{$Symbol}{"Header"} and not $CheckObjectsOnly);
128559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_ZTV")==0)
12856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip v-tables for templates, that should not be imported by applications
12857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($tr_name{$Symbol}=~/</);
12858dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(my $CName = $VTableClass{$Symbol})
12859dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
12860dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(not keys(%{$ClassMethods{$Level}{1}{$CName}}))
12861dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # vtables for "private" classes
128620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # use case: vtable for QDragManager (Qt 4.5.3 to 4.6.0) became HIDDEN symbol
12863dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    next;
12864dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
12865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
12866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
12868c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko            next if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level));
12869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"})
12871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # symbols for pure virtual methods cannot be called by clients
12872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
128741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
12875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1287862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub checkDump($$)
128791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
1288062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($LibVersion, $V) = @_;
1288162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"checkDump"}{$LibVersion}{$V}) {
1288262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"checkDump"}{$LibVersion}{$V};
1288362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1288462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"checkDump"}{$LibVersion}{$V} = (not $UsedDump{$LibVersion}{"V"} or cmpVersions($UsedDump{$LibVersion}{"V"}, $V)>=0));
128851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
128861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
128871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectAdded_H($)
12888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
128891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{2}}))
12891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
128921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
128931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
128941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
128951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
12896b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko
12897b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"Artificial"})
12898b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            { # skip artificial constructors
12899b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                next;
12900b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
129011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}
129031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"}) {
129041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
129051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1290662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
129091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
129101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"})
129111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
129121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{2}{"SrcBin"})
129131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
1291462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{1}{"BinOnly"} or not checkDump(1, "2.11"))
129151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # support for old and different (!) ABI dumps
129161693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{2}{$Symbol}{"Virt"}
129171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{2}{$Symbol}{"PureVirt"})
129181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129191693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
12920850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        {
12921850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{2}{$Symbol}{"Lang"})
12922850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12923850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12924850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12925850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12926850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
129281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129291693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
129301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
129311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 2, "-Deps"))
129320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            { # skip added inline symbols and const global data
129331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
129341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
129351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
129381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
129391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedInt{$Level}{$Symbol} = 1;
12940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
12941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
12942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
12943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
129441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectRemoved_H($)
12945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
129461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
12947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
12948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
129491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
129501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
129511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SN, $SS, $SV) = separate_symbol($Symbol);
129521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
129531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
129541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
129551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        or not $CompleteSignature{1}{$Symbol}{"MnglName"}) {
129561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
129571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
1295862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ExtendedSymbols{$Symbol}) {
12959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
12960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
129611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{2}{$Symbol}
129621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$Symbol}{"MnglName"})
12963850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
129641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($UsedDump{1}{"SrcBin"})
129651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
1296662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($UsedDump{2}{"BinOnly"} or not checkDump(2, "2.11"))
12967850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # support for old and different (!) ABI dumps
129681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    if(not $CompleteSignature{1}{$Symbol}{"Virt"}
129691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    and not $CompleteSignature{1}{$Symbol}{"PureVirt"})
129701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
129711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        if($CheckHeadersOnly)
129721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        { # skip all removed symbols
12973850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            if(my $Lang = $CompleteSignature{1}{$Symbol}{"Lang"})
12974850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            {
12975850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                if($Lang eq "C")
12976850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                { # support for old ABI dumps: missed extern "C" functions
12977850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                    next;
12978850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                }
12979850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                            }
129801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        else
129821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                        {
129831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            if(not link_symbol($Symbol, 1, "-Deps"))
129841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            { # skip removed inline symbols
129851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                                next;
129861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            }
129871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
129881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
129891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
129901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
12991b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not checkDump(1, "2.15"))
12992b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            {
12993b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                if($Symbol=~/_IT_E\Z/)
12994b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                { # _ZN28QExplicitlySharedDataPointerI22QSslCertificatePrivateEC1IT_EERKS_IT_E
12995b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                    next;
12996b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko                }
12997b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            }
129989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Class"})
129999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
130009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Short = $CompleteSignature{1}{$Symbol}{"ShortName"})
130019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
130029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(defined $Constants{2}{$Short})
130039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
130049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        my $Val = $Constants{2}{$Short}{"Value"};
130059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(defined $Func_ShortName{2}{$Val})
130069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # old name defined to new
130079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            next;
130089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
130099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
130109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
130119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
130129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
130131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RemovedInt{$Level}{$Symbol} = 1;
130141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
130151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # search for a source-compatible equivalent
130161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                setAlternative($Symbol, $Level);
130171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
13018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
130221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeHeaders($)
13023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
130241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
130251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
13026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking added symbols
13027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"PureVirt"});
130289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{2}{$Symbol}{"Private"});
130299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 2, "Affected", $Level));
13030850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
13031850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
13032850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{2}{$Symbol}{"InLine"})
13033850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
13034850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{2}{$Symbol}{"Virt"})
13035850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
13036850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
13037850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
13038850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
130391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
130411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
130421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($SourceAlternative_B{$Symbol}) {
130431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                next;
130441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Added_Symbol"}{""}}=();
13047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
130481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
13049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # checking removed symbols
13050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"PureVirt"});
130519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($CompleteSignature{1}{$Symbol}{"Private"});
130529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(not symbolFilter($Symbol, 1, "Affected", $Level));
13053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Level eq "Binary")
13054850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
13055850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"InLine"})
13056850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
13057850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                if(not $CompleteSignature{1}{$Symbol}{"Virt"})
13058850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                { # skip inline non-virtual functions
13059850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    next;
13060850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                }
13061850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
130621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
130641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Source
130650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(my $Alt = $SourceAlternative{$Symbol})
130660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
130670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Alt}
130680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"Const"})
130690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
1307062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
13071f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Removed_Const_Overload"}{"this"}}=(
1307262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        "Type_Name"=>$TypeInfo{1}{$Cid}{"Name"},
1307374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        "Target"=>get_Signature($Alt, 1));
130740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                else
130760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # do NOT show removed symbol
130770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    next;
130780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
130791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
130801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
130811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{"Removed_Symbol"}{""}}=();
13082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addParamNames($)
13086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibraryVersion = $_[0];
13088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not keys(%AddIntParams));
13089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SecondVersion = $LibraryVersion==1?2:1;
13090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompleteSignature{$LibraryVersion}}))
13091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not keys(%{$AddIntParams{$Interface}}));
13093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibraryVersion}{$Interface}{"Param"}}))
13094850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        { # add absent parameter names
13095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ParamName = $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"};
13096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamName=~/\Ap\d+\Z/ and my $NewParamName = $AddIntParams{$Interface}{$ParamPos})
13097850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            { # names from the external file
13098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(defined $CompleteSignature{$SecondVersion}{$Interface}
13099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and defined $CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos})
13100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CompleteSignature{$SecondVersion}{$Interface}{"Param"}{$ParamPos}{"name"}=~/\Ap\d+\Z/) {
13102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $CompleteSignature{$LibraryVersion}{$Interface}{"Param"}{$ParamPos}{"name"} = $NewParamName;
13107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectChangedTypedefs()
13114989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko{ # detect changed typedefs to show
13115989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko  # correct function signatures
13116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Typedef (keys(%{$Typedef_BaseName{1}}))
13117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
13118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Typedef);
13119989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName1 = $Typedef_BaseName{1}{$Typedef};
13120989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName1 or isAnon($BName1)) {
13121989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13122989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13123989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        my $BName2 = $Typedef_BaseName{2}{$Typedef};
13124989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if(not $BName2 or isAnon($BName2)) {
13125989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko            next;
13126989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        }
13127989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        if($BName1 ne $BName2) {
13128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedTypedef{$Typedef} = 1;
13129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_suffix($$)
13134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
131351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Symbol, $Full) = @_;
131361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($SN, $SO, $SV) = separate_symbol($Symbol);
13137570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Symbol=$SN; # remove version
131381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Signature = $tr_name{$Symbol};
131391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Suffix = substr($Signature, find_center($Signature, "("));
13140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Full) {
13141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Suffix=~s/(\))\s*(const volatile|volatile const|const|volatile)\Z/$1/g;
13142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Suffix;
13144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_symbol_prefix($$)
13147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
13148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
13149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ShortName = $CompleteSignature{$LibVersion}{$Symbol}{"ShortName"};
13150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $ClassId = $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
13151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # methods
1315262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $ShortName = $TypeInfo{$LibVersion}{$ClassId}{"Name"}."::".$ShortName;
13153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
13154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ShortName;
13155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
13156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
131571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub setAlternative($)
131581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
131591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Symbol = $_[0];
131601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $PSymbol = $Symbol;
131611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not defined $CompleteSignature{2}{$PSymbol}
131621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or (not $CompleteSignature{2}{$PSymbol}{"MnglName"}
131631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    and not $CompleteSignature{2}{$PSymbol}{"ShortName"}))
131641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # search for a pair
13165dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(my $ShortName = $CompleteSignature{1}{$PSymbol}{"ShortName"})
131661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
13167dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($CompleteSignature{1}{$PSymbol}{"Data"})
131681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
13169dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($PSymbol=~s/L(\d+$ShortName(E)\Z)/$1/
13170dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                or $PSymbol=~s/(\d+$ShortName(E)\Z)/L$1/)
131711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
131721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if(defined $CompleteSignature{2}{$PSymbol}
131731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $CompleteSignature{2}{$PSymbol}{"MnglName"})
131741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
131751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative{$Symbol} = $PSymbol;
131761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $SourceAlternative_B{$PSymbol} = $Symbol;
131771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(not defined $CompleteSignature{1}{$PSymbol}
131781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
131791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $SourceReplacement{$Symbol} = $PSymbol;
131801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
131811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
131821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
13183dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
13184dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            else
13185dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
13186dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                foreach my $Sp ("KV", "VK", "K", "V")
13187dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
13188dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if($PSymbol=~s/\A_ZN$Sp/_ZN/
13189dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    or $PSymbol=~s/\A_ZN/_ZN$Sp/)
13190dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    {
13191dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        if(defined $CompleteSignature{2}{$PSymbol}
13192dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        and $CompleteSignature{2}{$PSymbol}{"MnglName"})
13193dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        {
13194dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative{$Symbol} = $PSymbol;
13195dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            $SourceAlternative_B{$PSymbol} = $Symbol;
13196dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            if(not defined $CompleteSignature{1}{$PSymbol}
13197dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            or not $CompleteSignature{1}{$PSymbol}{"MnglName"}) {
13198dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                                $SourceReplacement{$Symbol} = $PSymbol;
13199dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                            }
13200dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        }
13201dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
13202dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $PSymbol = $Symbol;
13203dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
132041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
132051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
132071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "";
132081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
132091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
132100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getSymKind($$)
132110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
132120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
132130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($CompleteSignature{$LibVersion}{$Symbol}{"Data"})
132140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
132150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Global_Data";
132160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
132170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif($CompleteSignature{$LibVersion}{$Symbol}{"Class"})
132180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
132190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "Method";
132200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
132210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return "Function";
132220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
132230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
132248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub mergeSymbols($)
13225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
132261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
13227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SubProblems = ();
13228f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
132291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    mergeBases($Level);
132301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
13231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %AddedOverloads = ();
132321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$AddedInt{$Level}}))
13233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check all added exported symbols
132341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{2}{$Symbol}{"Header"}) {
13235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{1}{$Symbol}
132380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Header"})
132390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check added symbol
132400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
132411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13242850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 2, "Affected", $Level)) {
132431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
132471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $AddedOverloads{get_symbol_prefix($Symbol, 2)}{get_symbol_suffix($Symbol, 1)} = $Symbol;
13248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{2}{$Symbol}{"Override"})
132501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1325162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{2}{$Symbol}{"Class"};
1325262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{2}{$Cid}{"Name"};
132530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $CompleteSignature{1}{$OverriddenMethod} and $CompleteSignature{1}{$OverriddenMethod}{"Virt"}
13254ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and not $CompleteSignature{1}{$OverriddenMethod}{"Private"})
132550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{1}{$AffectedClass_Name})
132570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in previous version
132580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($TName_Tid{1}{$AffectedClass_Name}, 1))
132590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$OverriddenMethod}{"Overridden_Virtual_Method"}{$tr_name{$Symbol}}}=(
132610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
132620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($Symbol, 2),
132630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($OverriddenMethod, 2),
1326474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($Symbol, 2));
132650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
132701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$RemovedInt{$Level}}))
132711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # check all removed exported symbols
132721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}) {
13273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
132750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $CompleteSignature{2}{$Symbol}
132760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$Symbol}{"Header"})
132770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # double-check removed symbol
132780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            next;
132791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
132811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip private methods
132821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
13284850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected", $Level)) {
132851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
132861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
132871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
132881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(my $OverriddenMethod = $CompleteSignature{1}{$Symbol}{"Override"})
132891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register virtual overridings
1329062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $Cid = $CompleteSignature{1}{$Symbol}{"Class"};
1329162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $AffectedClass_Name = $TypeInfo{1}{$Cid}{"Name"};
13292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$OverriddenMethod}
132930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$OverriddenMethod}{"Virt"})
132940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
132950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($TName_Tid{2}{$AffectedClass_Name})
132960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # class should exist in newer version
132970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(not isCopyingClass($CompleteSignature{1}{$Symbol}{"Class"}, 1))
132980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    { # old v-table is NOT copied by old applications
132990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Overridden_Virtual_Method_B"}{$tr_name{$OverriddenMethod}}}=(
133000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Type_Name"=>$AffectedClass_Name,
133010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Target"=>get_Signature($OverriddenMethod, 1),
133020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            "Old_Value"=>get_Signature($Symbol, 1),
1330374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            "New_Value"=>get_Signature($OverriddenMethod, 1));
133040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
13305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Binary"
133091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $OSgroup eq "windows")
13310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # register the reason of symbol name change
1331162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $NewSym = $mangled_name{2}{$tr_name{$Symbol}})
13312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1331362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($AddedInt{$Level}{$NewSym})
13314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
1331562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Static"} ne $CompleteSignature{2}{$NewSym}{"Static"})
13316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1331762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Static"})
133181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
133191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Static"}{$tr_name{$Symbol}}}=(
133201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1332262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
133241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
133251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13326fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Static"}{$tr_name{$Symbol}}}=(
133271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1332962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1333262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Virt"} ne $CompleteSignature{2}{$NewSym}{"Virt"})
13333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
1333462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($CompleteSignature{2}{$NewSym}{"Virt"})
133351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
133361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Virtual"}{$tr_name{$Symbol}}}=(
133371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1333962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
133411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
133421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
13343fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Symbol_Became_Non_Virtual"}{$tr_name{$Symbol}}}=(
133441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Target"=>$tr_name{$Symbol},
133451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "Old_Value"=>$Symbol,
1334662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "New_Value"=>$NewSym  );
13347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1334962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId1 = $CompleteSignature{1}{$Symbol}{"Return"};
1335062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTId2 = $CompleteSignature{2}{$NewSym}{"Return"};
1335162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName1 = $TypeInfo{1}{$RTId1}{"Name"};
1335262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $RTName2 = $TypeInfo{2}{$RTId2}{"Name"};
1335362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($RTName1 ne $RTName2)
13354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Symbol_Changed_Return";
133561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"Data"}) {
13357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Global_Data_Symbol_Changed_Type";
13358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
133591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{$tr_name{$Symbol}}}=(
133601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1336162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Old_Type"=>$RTName1,
1336262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Type"=>$RTName2,
133631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1336462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
133691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/)
13370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C++
133711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Prefix = get_symbol_prefix($Symbol, 1);
13372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my @Overloads = sort keys(%{$AddedOverloads{$Prefix}})
133731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $AddedOverloads{$Prefix}{get_symbol_suffix($Symbol, 1)})
13374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # changed signature: params, "const"-qualifier
1337562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NewSym = $AddedOverloads{$Prefix}{$Overloads[0]};
133761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($CompleteSignature{1}{$Symbol}{"Constructor"})
133771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13378f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(C[1-2][EI])/)
13379989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $CtorType = $1;
13381f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(C[1-2][EI])/$CtorType/g;
13382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
133841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                elsif($CompleteSignature{1}{$Symbol}{"Destructor"})
133851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
13386f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($Symbol=~/(D[0-2][EI])/)
13387989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                    {
13388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $DtorType = $1;
13389f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $NewSym=~s/(D[0-2][EI])/$DtorType/g;
13390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13392dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $NS1 = $CompleteSignature{1}{$Symbol}{"NameSpace"};
1339362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $NS2 = $CompleteSignature{2}{$NewSym}{"NameSpace"};
13394dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if((not $NS1 and not $NS2) or ($NS1 and $NS2 and $NS1 eq $NS2))
13395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # from the same class and namespace
133961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Const"}
1339762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Const"})
13398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "const" to non-"const"
13399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Const"}{$tr_name{$Symbol}}}=(
1340062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Type_Name"=>$TypeInfo{1}{$CompleteSignature{1}{$Symbol}{"Class"}}{"Name"},
134011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1340262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
134031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1340462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
134061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Const"}
1340762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Const"})
13408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"const" to "const"
134090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Const"}{$tr_name{$Symbol}}}=(
134101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1341162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
134121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1341362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
134151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{1}{$Symbol}{"Volatile"}
1341662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and not $CompleteSignature{2}{$NewSym}{"Volatile"})
13417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # "volatile" to non-"volatile"
13418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
13419fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Volatile"}{$tr_name{$Symbol}}}=(
134201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1342162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
134221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1342362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
134251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not $CompleteSignature{1}{$Symbol}{"Volatile"}
1342662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    and $CompleteSignature{2}{$NewSym}{"Volatile"})
13427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # non-"volatile" to "volatile"
134280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Volatile"}{$tr_name{$Symbol}}}=(
134291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1343062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
134311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1343262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
1343462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if(get_symbol_suffix($Symbol, 0) ne get_symbol_suffix($NewSym, 0))
13435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # params list
134361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Symbol_Changed_Parameters"}{$tr_name{$Symbol}}}=(
134371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Target"=>$tr_name{$Symbol},
1343862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Signature"=>get_Signature($NewSym, 2),
134391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "Old_Value"=>$Symbol,
1344062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "New_Value"=>$NewSym  );
13441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
134461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
134471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # checking symbols
13448f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $CurrentSymbol = $Symbol;
13449f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
134501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
134511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source")
134521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # remove symbol version
134531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Symbol=$SN;
134541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
134561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # Binary
134571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $SV)
134581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # symbol without version
134591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(my $VSym = $SymVer{1}{$Symbol})
134601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # the symbol is linked with versioned symbol
134611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($CompleteSignature{2}{$VSym}{"MnglName"})
134621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # show report for symbol@ver only
134631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
134651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif(not link_symbol($VSym, 2, "-Deps"))
134661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # changed version: sym@v1 to sym@v2
134671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                      # do NOT show report for symbol
134681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        next;
134691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
13470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PSymbol = $Symbol;
134741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Source"
134751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and my $S = $SourceReplacement{$Symbol})
134761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # take a source-compatible replacement function
134771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $PSymbol = $S;
134781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"Private"})
13480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # private symbols
13481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not defined $CompleteSignature{1}{$Symbol}
134841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not defined $CompleteSignature{2}{$PSymbol})
134851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no info
134861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
134871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
134881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"MnglName"}
134891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"MnglName"})
134901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # no mangled name
13491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"Header"}
134941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or not $CompleteSignature{2}{$PSymbol}{"Header"})
13495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # without a header
13496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
134989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
134999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $CompleteSignature{1}{$Symbol}{"PureVirt"}
135009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"PureVirt"})
135019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became pure
135029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
135039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
135049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
135059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"PureVirt"})
135069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # became non-pure
135079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
135089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
135099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
135109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Affected + InlineVirt", $Level))
135119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
135129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
135139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
135149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not symbolFilter($PSymbol, 2, "Affected + InlineVirt", $Level))
135159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # exported, target, inline virtual and pure virtual
135169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next;
135179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
135189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
1351962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.13") and checkDump(2, "2.13"))
135200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"}
135220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Data"})
135230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
135240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value1 = $CompleteSignature{1}{$Symbol}{"Value"};
135250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                my $Value2 = $CompleteSignature{2}{$PSymbol}{"Value"};
135260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if(defined $Value1)
135270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                {
135280d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value1 = showVal($Value1, $CompleteSignature{1}{$Symbol}{"Return"}, 1);
135290d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    if(defined $Value2)
135300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    {
135310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        $Value2 = showVal($Value2, $CompleteSignature{2}{$PSymbol}{"Return"}, 2);
135320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        if($Value1 ne $Value2)
135330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        {
135340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Global_Data_Value_Changed"}{""}}=(
135350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Old_Value"=>$Value1,
135360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "New_Value"=>$Value2,
135370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                "Target"=>get_Signature($Symbol, 1)  );
135380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        }
135390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    }
135400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
135410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
135420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
13543850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
135440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Private"})
135450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Private"}{""}}=(
135470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(not $CompleteSignature{1}{$Symbol}{"Protected"}
135500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and $CompleteSignature{2}{$PSymbol}{"Protected"})
135510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Protected"}{""}}=(
135530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif($CompleteSignature{1}{$Symbol}{"Protected"}
135560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        and not $CompleteSignature{2}{$PSymbol}{"Protected"})
135570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
135580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{getSymKind($Symbol, 1)."_Became_Public"}{""}}=(
135590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>get_Signature_M($PSymbol, 2)  );
135600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
135610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
13562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking virtual table
135631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        mergeVirtualTables($Symbol, $Level);
135641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
13565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($COMPILE_ERRORS)
13566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # if some errors occurred at the compiling stage
13567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # then some false positives can be skipped here
135681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if(not $CompleteSignature{1}{$Symbol}{"Data"} and $CompleteSignature{2}{$PSymbol}{"Data"}
1356962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $GlobalDataObject{2}{$Symbol})
13570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # missed information about parameters in newer version
13571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
1357362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"} and not $GlobalDataObject{1}{$Symbol}
135741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Data"})
135759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # missed information about parameters in older version
13576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
13577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($MnglName, $VersionSpec, $SymbolVersion) = separate_symbol($Symbol);
13580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking attributes
135811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{2}{$PSymbol}{"Static"}
135829927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
135841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Static"}{""}}=(
135851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif(not $CompleteSignature{2}{$PSymbol}{"Static"}
135899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        and $CompleteSignature{1}{$Symbol}{"Static"} and $Symbol=~/\A(_Z|\?)/)
135909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
13591fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Method_Became_Non_Static"}{""}}=(
135921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                "Target"=>get_Signature($Symbol, 1)
135931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            );
13594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
135951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(($CompleteSignature{1}{$Symbol}{"Virt"} and $CompleteSignature{2}{$PSymbol}{"Virt"})
135961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or ($CompleteSignature{1}{$Symbol}{"PureVirt"} and $CompleteSignature{2}{$PSymbol}{"PureVirt"}))
13597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # relative position of virtual and pure virtual methods
135981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
13599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13600dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if(defined $CompleteSignature{1}{$Symbol}{"RelPos"} and defined $CompleteSignature{2}{$PSymbol}{"RelPos"}
13601dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $CompleteSignature{1}{$Symbol}{"RelPos"}!=$CompleteSignature{2}{$PSymbol}{"RelPos"})
13602dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                { # top-level virtual methods only
136031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Class_Id = $CompleteSignature{1}{$Symbol}{"Class"};
1360462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $Class_Name = $TypeInfo{1}{$Class_Id}{"Name"};
13605dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    if(defined $VirtualTable{1}{$Class_Name} and defined $VirtualTable{2}{$Class_Name}
13606dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    and $VirtualTable{1}{$Class_Name}{$Symbol}!=$VirtualTable{2}{$Class_Name}{$Symbol})
136071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    { # check the absolute position of virtual method (including added and removed methods)
1360862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my %Class_Type = get_Type($Class_Id, 1);
136091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $ProblemType = "Virtual_Method_Position";
136101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($CompleteSignature{1}{$Symbol}{"PureVirt"}) {
136111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $ProblemType = "Pure_Virtual_Method_Position";
136121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
136131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if(isUsedClass($Class_Id, 1, $Level))
13614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
136151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            my @Affected = ($Symbol, keys(%{$OverriddenMethods{1}{$Symbol}}));
136169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            foreach my $ASymbol (@Affected)
136171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            {
136189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                if(not symbolFilter($ASymbol, 1, "Affected", $Level)) {
136199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                    next;
136209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                }
136219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                                %{$CompatProblems{$Level}{$ASymbol}{$ProblemType}{$tr_name{$MnglName}}}=(
136221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Type_Name"=>$Class_Type{"Name"},
136231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "Old_Value"=>$CompleteSignature{1}{$Symbol}{"RelPos"},
136241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Value"=>$CompleteSignature{2}{$PSymbol}{"RelPos"},
1362574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                                    "Target"=>get_Signature($Symbol, 1));
136261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
136271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $VTableChanged_M{$Class_Type{"Name"}} = 1;
13628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
136331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{1}{$Symbol}{"PureVirt"}
136341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $CompleteSignature{2}{$PSymbol}{"PureVirt"})
13635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT check type changes in pure virtuals
13636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
13637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13638ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
136391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Symbol=~/\A(_Z|\?)/
136401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})==keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C/C++: changes in parameters
136421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking parameters
13644ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 1);
13645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
13648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # C: added/removed parameters
136491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}}))
13650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking added parameters
13651dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
1365262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType2_Name = $TypeInfo{2}{$PType2_Id}{"Name"};
1365362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType2_Name eq "...");
1365462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1365562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PName_Old = (defined $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos})?$CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"}:"";
13656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_Prev = "-1";
1365762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # added unnamed parameter ( pN )
1365962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 1);
1366062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType2_Name, $ParamPos, "backward", $Symbol, 2);
13661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions1==-1 or $#Positions2>$#Positions1) {
13662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_Prev = "lost";
13663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
1366662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ParamPos_Prev = find_ParamPair_Pos_byName($PName, $Symbol, 1);
13667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_Prev eq "lost")
13669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
136701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Added_Parameter";
1367362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Added_Unnamed_Parameter";
13675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
136760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1367762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Target"=>$PName,
13678f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1367962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType2_Name,
136801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
13683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13684f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType2_Id, $TypeInfo{2});
1368562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
13686f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{1});
1368762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType2_Name eq $TypeInfo{1}{$PairType_Id}{"Name"})
1368862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_Old, $Symbol, 2) eq "lost")
13689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
1369062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName_Old!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
136920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
1369362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Target"=>$PName_Old,
13694f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1369562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType2_Name,
1369662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Old_Value"=>$PName_Old,
1369762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "New_Value"=>$PName,
136981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Added_Middle_Parameter";
1370462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Added_Middle_Unnamed_Parameter";
13706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
137070d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
1370862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Target"=>$PName,
13709f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1371062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType2_Name,
137111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
137161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # check relevant parameters
13718dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
137191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $ParamName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # FIXME: find relevant parameter by name
137211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})
13722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13723dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
137241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $ParamName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"};
1372562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TypeInfo{1}{$PType1_Id}{"Name"} eq $TypeInfo{2}{$PType2_Id}{"Name"}
1372662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    or ($ParamName1!~/\Ap\d+\Z/i and $ParamName1 eq $ParamName2)) {
13727ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        mergeParameters($Symbol, $PSymbol, $ParamPos, $ParamPos, $Level, 0);
13728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
137311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $ParamPos (sort {int($a) <=> int($b)} keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # checking removed parameters
13733dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"type"};
1373462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $PType1_Name = $TypeInfo{1}{$PType1_Id}{"Name"};
1373562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                last if($PType1_Name eq "...");
13736ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos}{"name"};
13737ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $PName_New = (defined $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos})?$CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"name"}:"";
13738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ParamPos_New = "-1";
13739ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if($PName=~/\Ap\d+\Z/i)
13740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # removed unnamed parameter ( pN )
1374162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions1 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 1);
1374262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my @Positions2 = find_ParamPair_Pos_byTypeAndPos($PType1_Name, $ParamPos, "forward", $Symbol, 2);
13743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($#Positions2==-1 or $#Positions2<$#Positions1) {
13744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ParamPos_New = "lost";
13745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
13748ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    $ParamPos_New = find_ParamPair_Pos_byName($PName, $Symbol, 2);
13749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($ParamPos_New eq "lost")
13751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
137521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($ParamPos>keys(%{$CompleteSignature{2}{$PSymbol}{"Param"}})-1)
13753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemType = "Removed_Parameter";
13755ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        if($PName=~/\Ap\d+\Z/) {
13756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ProblemType = "Removed_Unnamed_Parameter";
13757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
137580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13759ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            "Target"=>$PName,
13760f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1376162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            "Param_Type"=>$PType1_Name,
137621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            "New_Signature"=>get_Signature($Symbol, 2)  );
13763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
137641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($ParamPos<keys(%{$CompleteSignature{1}{$Symbol}{"Param"}})-1)
13765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
13766f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %ParamType_Pure = get_PureType($PType1_Id, $TypeInfo{1});
1376762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        my $PairType_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos}{"type"};
13768f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        my %PairType_Pure = get_PureType($PairType_Id, $TypeInfo{2});
1376962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        if(($ParamType_Pure{"Name"} eq $PairType_Pure{"Name"} or $PType1_Name eq $TypeInfo{2}{$PairType_Id}{"Name"})
13770ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        and find_ParamPair_Pos_byName($PName_New, $Symbol, 1) eq "lost")
13771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13772ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName_New!~/\Ap\d+\Z/ and $PName!~/\Ap\d+\Z/)
13773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
137740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos)." Parameter"}}=(
13775ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Target"=>$PName,
13776f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1377762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                    "Param_Type"=>$PType1_Name,
13778ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "Old_Value"=>$PName,
13779ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                    "New_Value"=>$PName_New,
137801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    "New_Signature"=>get_Signature($Symbol, 2)  );
13781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
13782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else
13784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
13785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $ProblemType = "Removed_Middle_Parameter";
13786ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                            if($PName=~/\Ap\d+\Z/) {
13787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemType = "Removed_Middle_Unnamed_Parameter";
13788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
137890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{$ProblemType}{showPos($ParamPos)." Parameter"}}=(
13790ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                                "Target"=>$PName,
13791f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos, $Symbol, 2),
1379262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                "Param_Type"=>$PType1_Name,
137931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                "New_Signature"=>get_Signature($Symbol, 2)  );
13794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
13795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking return type
138001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType1_Id = $CompleteSignature{1}{$Symbol}{"Return"};
138011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $ReturnType2_Id = $CompleteSignature{2}{$PSymbol}{"Return"};
13802f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %RC_SubProblems = detectTypeChange($ReturnType1_Id, $ReturnType2_Id, "Return", $Level);
13803fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13804f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubProblemType (keys(%RC_SubProblems))
13805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13806f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $New_Value = $RC_SubProblems{$SubProblemType}{"New_Value"};
13807f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Old_Value = $RC_SubProblems{$SubProblemType}{"Old_Value"};
13808fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %ProblemTypes = ();
13809f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13810fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
13812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type_And_Size") {
13813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_And_Size"} = 1;
13814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13815fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_Format") {
13816fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type_Format"} = 1;
13817fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13818fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
13819fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $ProblemTypes{"Global_Data_Type"} = 1;
13820fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
13821fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13822fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13823fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13824fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13825fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13827fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RR = removedQual($Old_Value, $New_Value, "const"))
13828fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # const to non-const
13829fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RR==2) {
13830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Removed_Const"} = 1;
13831fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13832fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Non_Const"} = 1;
13834fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13837fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    elsif(my $RA = addedQual($Old_Value, $New_Value, "const"))
13838fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # non-const to const
13839fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13840fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Added_Const"} = 1;
13841fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13842fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13843fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Global_Data_Became_Const"} = 1;
13844fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13845fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $ProblemTypes{"Global_Data_Type"} = 1;
13846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13848fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13849fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else
13850fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13851fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                # quals
13852fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($SubProblemType eq "Return_Type"
13853fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13854fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
13856fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(checkDump(1, "2.6") and checkDump(2, "2.6"))
13857fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13858fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(addedQual($Old_Value, $New_Value, "volatile"))
13859fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
13860fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Value_Became_Volatile"} = 1;
13861fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Level ne "Source"
13862fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13863fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                $ProblemTypes{"Return_Type"} = 1;
13864fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13865fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13866fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13867fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(my $RA = addedQual($Old_Value, $New_Value, "const"))
138689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
13869fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($RA==2) {
13870fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Added_Const"} = 1;
13871fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13872fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        else {
13873fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Const"} = 1;
13874fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13875fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Level ne "Source"
13876fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or not cmpBTypes($Old_Value, $New_Value, 1, 2)) {
13877fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type"} = 1;
13878fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
13880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
13881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
13882f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Level eq "Binary"
13883f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            and not $CompleteSignature{1}{$Symbol}{"Data"})
13884f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            {
13885f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my ($Arch1, $Arch2) = (getArch(1), getArch(2));
13886f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Arch1 eq "unknown" or $Arch2 eq "unknown")
13887f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                { # if one of the architectures is unknown
13888f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    # then set other arhitecture to unknown too
13889f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    ($Arch1, $Arch2) = ("unknown", "unknown");
13890f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13891f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                my (%Conv1, %Conv2) = ();
13892fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($UseConv_Real{1}{"R"} and $UseConv_Real{2}{"R"})
13893f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13894f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Real($CompleteSignature{1}{$Symbol});
13895f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Real($CompleteSignature{2}{$PSymbol});
13896f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13897f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                else
13898f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13899f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv1 = callingConvention_R_Model($CompleteSignature{1}{$Symbol}, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
13900f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    %Conv2 = callingConvention_R_Model($CompleteSignature{2}{$PSymbol}, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
13901f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13902f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
13903f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($SubProblemType eq "Return_Type_Became_Void")
13904f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13905f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13906f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13907f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack") {
13908fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Stack_Layout"} = 1;
13909f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13910f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv1{"Hidden"}) {
13911fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_Became_Void_And_Register"} = 1;
13912f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13913f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13914f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13915f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type_From_Void")
13916f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13917f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if(keys(%{$CompleteSignature{1}{$Symbol}{"Param"}}))
13918f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    { # parameters stack has been affected
13919f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv2{"Method"} eq "stack") {
13920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Stack_Layout"} = 1;
13921f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13922f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        elsif($Conv2{"Hidden"}) {
13923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Void_And_Register"} = 1;
13924f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13925f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13926f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13927f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($SubProblemType eq "Return_Type"
13928f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_And_Size"
13929f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                or $SubProblemType eq "Return_Type_Format")
13930f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
13931f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Method"} ne $Conv2{"Method"})
13932f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13933f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "stack")
13934f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        { # returns in a register instead of a hidden first parameter
13935fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Stack_To_Register"} = 1;
13936f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13937f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        else {
13938fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $ProblemTypes{"Return_Type_From_Register_To_Stack"} = 1;
13939f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13940f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13941f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    else
13942f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    {
13943f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        if($Conv1{"Method"} eq "reg")
13944f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        {
13945f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            if($Conv1{"Registers"} ne $Conv2{"Registers"})
13946f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            {
13947f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                if($Conv1{"Hidden"}) {
13948fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Was_Hidden_Parameter"} = 1;
13949f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13950f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                elsif($Conv2{"Hidden"}) {
13951fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register_Became_Hidden_Parameter"} = 1;
13952f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13953f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                else {
13954fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    $ProblemTypes{"Return_Type_And_Register"} = 1;
13955f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                                }
13956f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            }
13957f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        }
13958f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
13959f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                }
13960f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
13961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13962fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not keys(%ProblemTypes))
13963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # default
13964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $ProblemTypes{$SubProblemType} = 1;
13965fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
13966fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13967fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $ProblemType (keys(%ProblemTypes))
13968fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # additional
13969f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $CompatProblems{$Level}{$Symbol}{$ProblemType}{"retval"} = $RC_SubProblems{$SubProblemType};
139709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
13971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
13972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ReturnType1_Id and $ReturnType2_Id)
13973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
13974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @RecurTypes = ();
13975f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Sub_SubProblems = mergeTypes($ReturnType1_Id, $ReturnType2_Id, $Level);
13976f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
13977f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $AddProblems = {};
13978fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
13979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Data"})
13980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
13981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Level eq "Binary")
13982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
13983fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(get_PLevel($ReturnType1_Id, 1)==0)
13984fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13985f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
13986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        { # add "Global_Data_Size" problem
13987f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $New_Value = $Sub_SubProblems->{$SubProblemType}{"New_Value"};
13988f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            my $Old_Value = $Sub_SubProblems->{$SubProblemType}{"Old_Value"};
13989fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($SubProblemType eq "DataType_Size")
13990fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            { # add a new problem
13991f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $AddProblems->{"Global_Data_Size"} = $Sub_SubProblems->{$SubProblemType};
13992fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
13993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
13994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
13995f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if(not defined $AddProblems->{"Global_Data_Size"})
13996fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
13997fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if(defined $GlobalDataObject{1}{$Symbol}
13998fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        and defined $GlobalDataObject{2}{$Symbol})
13999fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        {
14000fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $Old_Size = $GlobalDataObject{1}{$Symbol};
14001fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            my $New_Size = $GlobalDataObject{2}{$Symbol};
14002fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            if($Old_Size!=$New_Size)
14003fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            {
14004f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                $AddProblems->{"Global_Data_Size"}{"retval"} = {
14005fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                                    "Old_Size"=>$Old_Size*$BYTE_SIZE,
14006f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                    "New_Size"=>$New_Size*$BYTE_SIZE };
14007fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            }
14008fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        }
14009fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14010fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14011fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14012f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14013f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$AddProblems}))
14014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14015f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$AddProblems->{$SubProblemType}}))
14016ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $NewLocation = ($SubLocation)?"retval->".$SubLocation:"retval";
14018f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $AddProblems->{$SubProblemType}{$SubLocation};
14019f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
14020f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
14021f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14022f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14023f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
14024f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14025f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                {
14026f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $NewLocation = ($SubLocation)?"retval->".$SubLocation:"retval";
14027f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # checking object type
1403362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId1 = $CompleteSignature{1}{$Symbol}{"Class"};
1403462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $ObjTId2 = $CompleteSignature{2}{$PSymbol}{"Class"};
1403562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($ObjTId1 and $ObjTId2
140361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and not $CompleteSignature{1}{$Symbol}{"Static"})
14037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1403862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr1_Id = getTypeIdByName($TypeInfo{1}{$ObjTId1}{"Name"}."*const", 1);
1403962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my $ThisPtr2_Id = getTypeIdByName($TypeInfo{2}{$ObjTId2}{"Name"}."*const", 2);
14040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ThisPtr1_Id and $ThisPtr2_Id)
14041ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @RecurTypes = ();
14043f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Sub_SubProblems = mergeTypes($ThisPtr1_Id, $ThisPtr2_Id, $Level);
14044f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14046f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
14048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $NewLocation = ($SubLocation)?"this->".$SubLocation:"this";
14049f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $CompatProblems{$Level}{$Symbol}{$SubProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
140551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
140561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeVTables($Level);
140571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
14058850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (keys(%{$CompatProblems{$Level}})) {
14059850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $CheckedSymbols{$Level}{$Symbol} = 1;
14060850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
14061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
140630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub rmQuals($$)
140640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
140660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
140670d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
140680d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140690d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Qual eq "all")
140700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # all quals
140710d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Qual = "const|volatile|restrict";
140720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1407362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~s/\b$Qual\b//) {
140749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Value = formatName($Value, "T");
140750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
140760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
140770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub cmpBTypes($$$$)
140800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($T1, $T2, $V1, $V2) = @_;
140820d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T1 = uncover_typedefs($T1, $V1);
140830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $T2 = uncover_typedefs($T2, $V2);
140840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return (rmQuals($T1, "all") eq rmQuals($T2, "all"));
140850d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140860d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140870d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub addedQual($$$)
140880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
140890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14090fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($New_Value, $Old_Value, 2, 1, $Qual);
140910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
140931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub removedQual($$$)
14094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
140951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Old_Value, $New_Value, $Qual) = @_;
14096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return removedQual_I($Old_Value, $New_Value, 1, 2, $Qual);
140970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
140980d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub removedQual_I($$$$$)
141000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Old_Value, $New_Value, $V1, $V2, $Qual) = @_;
141020d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Old_Value = uncover_typedefs($Old_Value, $V1);
141030d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $New_Value = uncover_typedefs($New_Value, $V2);
141040d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Old_Value eq $New_Value)
141050d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # equal types
14106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1410862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Old_Value!~/\b$Qual\b/)
141090d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # without a qual
141100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 0;
141110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
1411262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    elsif($New_Value!~/\b$Qual\b/)
141130d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # became non-qual
141140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return 1;
141150d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    else
141170d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
141180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ1 = getQualModel($Old_Value, $Qual);
141190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my @BQ2 = getQualModel($New_Value, $Qual);
141200d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        foreach (0 .. $#BQ1)
141210d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # removed qual
141220d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($BQ1[$_]==1
141230d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            and $BQ2[$_]!=1)
141240d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
141250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 2;
141260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
14127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
141320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub getQualModel($$)
141330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $Qual) = @_;
141350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Qual) {
141360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return $Value;
141370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # cleaning
1414062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    while($Value=~/(\w+)/ and $1 ne $Qual) {
1414162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Value=~s/\b$1\b//g;
141420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Value=~s/[^\*\&\w]+//g;
141440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # modeling
141460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int*const*const == 011
141470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # int**const == 001
141480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Model = ();
141490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my @Elems = split(/[\*\&]/, $Value);
141500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not @Elems) {
141510d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return (0);
141520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    foreach (@Elems)
141540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    {
141550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if($_ eq $Qual) {
141560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 1);
141570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else {
141590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            push(@Model, 0);
141600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
141610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141620d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141630d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return @Model;
141640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
141650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
141664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %StringTypes = map {$_=>1} (
141674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char*",
141684b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const*"
141694b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141714b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenkomy %CharTypes = map {$_=>1} (
141724b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char",
141734b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    "char const"
141744b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko);
141754b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
141760d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub showVal($$$)
141770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko{
141780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Value, $TypeId, $LibVersion) = @_;
14179f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %PureType = get_PureType($TypeId, $TypeInfo{$LibVersion});
14180a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $TName = uncover_typedefs($PureType{"Name"}, $LibVersion);
1418101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(substr($Value, 0, 2) eq "_Z")
1418201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
1418301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(my $Unmangled = $tr_name{$Value}) {
1418401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            return $Unmangled;
1418501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1418601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
141874b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $StringTypes{$TName} or $TName=~/string/i)
141880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # strings
141890d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\"$Value\"";
141900d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    elsif(defined $CharTypes{$TName})
141920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # characters
141930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return "\'$Value\'";
141940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
141954b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($Value eq "")
141964b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    { # other
141974b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        return "\'\'";
141984b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    }
141990d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    return $Value;
142000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko}
142010d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
14202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub getRegs($$$)
14203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
14204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Symbol, $Pos) = @_;
14205fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14206fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}{"Reg"})
14207fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14208fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my %Regs = ();
14209fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Elem (sort keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}}))
14210fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14211ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if($Elem=~/\A$Pos([\.\+]|\Z)/) {
14212fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Regs{$CompleteSignature{$LibVersion}{$Symbol}{"Reg"}{$Elem}} = 1;
14213fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14214fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14215fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14216fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return join(", ", sort keys(%Regs));
14217fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14218fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14219fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return undef;
14220fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
14221fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14222ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenkosub mergeParameters($$$$$$)
14223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14224ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    my ($Symbol, $PSymbol, $ParamPos1, $ParamPos2, $Level, $ChkRnmd) = @_;
142250d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $Symbol) {
142260d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
142270d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14228dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType1_Id = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"type"};
14229dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName1 = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"name"};
14230dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PType2_Id = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"type"};
14231dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $PName2 = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"name"};
142320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(not $PType1_Id
142330d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    or not $PType2_Id) {
142340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        return;
142350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
14236ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14237f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($Symbol=~/\A(_Z|\?)/)
14238177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # do not merge "this"
14239177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if($PName1 eq "this" or $PName2 eq "this") {
14240177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            return;
14241177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
14242ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    }
14243ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
1424462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($PType1_Id, 1);
1424562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($PType2_Id, 2);
1424662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType1 = get_BaseType($PType1_Id, 1);
1424762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %BaseType2 = get_BaseType($PType2_Id, 2);
142480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Parameter_Location = ($PName1)?$PName1:showPos($ParamPos1)." Parameter";
14249ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
142501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
142511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
1425262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(checkDump(1, "2.6.1") and checkDump(2, "2.6.1"))
142531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # "reg" attribute added in ACC 1.95.1 (dump 2.6.1 format)
142541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and not $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Non_Register"}{$Parameter_Location}}=(
14258dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14259f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
142601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
142611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            elsif(not $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"reg"}
142621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"reg"})
142631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
142641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Became_Register"}{$Parameter_Location}}=(
14265dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    "Target"=>$PName1,
14266f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1)  );
142671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
14268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14269fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14270fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $UsedDump{1}{"DWARF"}
14271fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and defined $UsedDump{2}{"DWARF"})
14272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14273fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "3.0") and checkDump(2, "3.0"))
14274fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Old_Regs = getRegs(1, $Symbol, $ParamPos1);
14276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $New_Regs = getRegs(2, $PSymbol, $ParamPos2);
14277fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Old_Regs and $New_Regs)
14278fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Regs ne $New_Regs)
14280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Register"}{$Parameter_Location}}=(
14282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Target"=>$PName1,
14283f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14284fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "Old_Value"=>$Old_Regs,
14285fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            "New_Value"=>$New_Regs  );
14286fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14287fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14288fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif($Old_Regs and not $New_Regs)
14289fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_From_Register"}{$Parameter_Location}}=(
14291fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$PName1,
14292f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14293fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Old_Value"=>$Old_Regs  );
14294fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14295fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(not $Old_Regs and $New_Regs)
14296fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14297fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_To_Register"}{$Parameter_Location}}=(
14298fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "Target"=>$PName1,
14299f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14300fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        "New_Value"=>$New_Regs  );
14301fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14302fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if((my $Old_Offset = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"offset"}) ne ""
14303fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and (my $New_Offset = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"offset"}) ne "")
14304fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
14305fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Old_Offset ne $New_Offset)
14306fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    {
14307f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start1 = $CompleteSignature{1}{$Symbol}{"Param"}{0}{"offset"};
14308f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        my $Start2 = $CompleteSignature{2}{$Symbol}{"Param"}{0}{"offset"};
14309f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14310f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $Old_Offset = $Old_Offset - $Start1;
14311f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        $New_Offset = $New_Offset - $Start2;
14312f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14313f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if($Old_Offset ne $New_Offset)
14314f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
14315f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Changed_Offset"}{$Parameter_Location}}=(
14316f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Target"=>$PName1,
14317f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14318f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "Old_Value"=>$Old_Offset,
14319f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                                "New_Value"=>$New_Offset  );
14320f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
14321fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
14322fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14323fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14324fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14326177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(checkDump(1, "2.0") and checkDump(2, "2.0")
14327177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    and $UsedDump{1}{"V"} ne "3.1" and $UsedDump{2}{"V"} ne "3.1")
14328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # "default" attribute added in ACC 1.22 (dump 2.0 format)
14329177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko      # broken in 3.1, fixed in 3.2
143300d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_Old = $CompleteSignature{1}{$Symbol}{"Param"}{$ParamPos1}{"default"};
143310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        my $Value_New = $CompleteSignature{2}{$PSymbol}{"Param"}{$ParamPos2}{"default"};
1433262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1433362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        and checkDump(2, "2.13"))
143340d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # support for old ABI dumps
143350d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_Old and defined $Value_New)
143360d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            {
143370d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Type1{"Name"} eq "bool"
143380d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                and $Value_Old eq "false" and $Value_New eq "0")
143390d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # int class::method ( bool p = 0 );
143400d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # old ABI dumps: "false"
143410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                  # new ABI dumps: "0"
143420d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    $Value_Old = "0";
143430d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                }
14344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1434601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not checkDump(1, "2.18")
1434701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and checkDump(2, "2.18"))
1434801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # support for old ABI dumps
1434901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(not defined $Value_Old
1435001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            and substr($Value_New, 0, 2) eq "_Z") {
1435101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                $Value_Old = $Value_New;
1435201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
1435301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
143540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        if(defined $Value_Old)
14355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
143560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_Old = showVal($Value_Old, $PType1_Id, 1);
143570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if(defined $Value_New)
14358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Value_New = showVal($Value_New, $PType2_Id, 2);
143600d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                if($Value_Old ne $Value_New)
143610d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                { # FIXME: how to distinguish "0" and 0 (NULL)
143621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Changed"}{$Parameter_Location}}=(
14363dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Target"=>$PName1,
14364f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143650d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "Old_Value"=>$Value_Old,
143660d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                        "New_Value"=>$Value_New  );
14367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
143711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Removed"}{$Parameter_Location}}=(
143720d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Target"=>$PName1,
14373f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143740d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    "Old_Value"=>$Value_Old  );
14375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
143770d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        elsif(defined $Value_New)
143780d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
143790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Value_New = showVal($Value_New, $PType2_Id, 2);
143800d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Parameter_Default_Value_Added"}{$Parameter_Location}}=(
143810d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "Target"=>$PName1,
14382f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
143830d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                "New_Value"=>$Value_New  );
143840d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
14385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14386ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14387ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    if($ChkRnmd)
14388ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko    {
14389ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($PName1 and $PName2 and $PName1 ne $PName2
14390ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PType1_Id!=-1 and $PType2_Id!=-1
14391ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and $PName1!~/\Ap\d+\Z/ and $PName2!~/\Ap\d+\Z/)
14392ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # except unnamed "..." value list (Id=-1)
14393ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            %{$CompatProblems{$Level}{$Symbol}{"Renamed_Parameter"}{showPos($ParamPos1)." Parameter"}}=(
14394ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Target"=>$PName1,
14395f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
14396ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Param_Type"=>$TypeInfo{1}{$PType1_Id}{"Name"},
14397ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "Old_Value"=>$PName1,
14398ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Value"=>$PName2,
14399ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                "New_Signature"=>get_Signature($Symbol, 2)  );
14400ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
14401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14402ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
14403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type change (replace)
14404dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my %SubProblems = detectTypeChange($PType1_Id, $PType2_Id, "Parameter", $Level);
14405f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # add new problems, remove false alarms
14408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14410fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14411fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # quals
14412fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($SubProblemType eq "Parameter_Type"
14413fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_And_Size"
14414fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type_Format")
14415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1441662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14418fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(addedQual($Old_Value, $New_Value, "restrict")) {
144190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Restrict"}} = %{$SubProblems{$SubProblemType}};
144201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14421fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                elsif(removedQual($Old_Value, $New_Value, "restrict")) {
14422fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Restrict"}} = %{$SubProblems{$SubProblemType}};
14423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14424fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14425fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(checkDump(1, "2.6") and checkDump(2, "2.6"))
14426fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14427fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(removedQual($Old_Value, $New_Value, "volatile")) {
14428fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Volatile"}} = %{$SubProblems{$SubProblemType}};
14429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Type2{"Type"} eq "Const" and $BaseType2{"Name"} eq $Type1{"Name"}
14432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # int to "int const"
14434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif($Type1{"Type"} eq "Const" and $BaseType1{"Name"} eq $Type2{"Name"}
14437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2{"Type"}=~/Intrinsic|Class|Struct|Union|Enum/)
14438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "int const" to int
14439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($SubProblems{$SubProblemType});
14440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14441fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            elsif(my $RR = removedQual($Old_Value, $New_Value, "const"))
14442fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # "const" to non-"const"
14443fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($RR==2) {
14444fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Removed_Const"}} = %{$SubProblems{$SubProblemType}};
14445fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14446fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else {
14447fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    %{$SubProblems{"Parameter_Became_Non_Const"}} = %{$SubProblems{$SubProblemType}};
14448fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14449fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14452fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14453fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Level eq "Source")
14454fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
14455fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14456fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
14457fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14458fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14459fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14460fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($SubProblemType eq "Parameter_Type")
14461fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
14462fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(cmpBTypes($Old_Value, $New_Value, 1, 2)) {
14463fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    delete($SubProblems{$SubProblemType});
14464fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
14465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
14466fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
14467fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $SubProblemType (keys(%SubProblems))
14470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # modify/register problems
14471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $New_Value = $SubProblems{$SubProblemType}{"New_Value"};
14472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Old_Value = $SubProblems{$SubProblemType}{"Old_Value"};
14473f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $New_Size = $SubProblems{$SubProblemType}{"New_Size"};
14474f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        my $Old_Size = $SubProblems{$SubProblemType}{"Old_Size"};
14475fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $NewProblemType = $SubProblemType;
14477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Old_Value eq "..." and $New_Value ne "...")
14478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "..." to "int"
14479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos1==0)
14480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $NewProblemType = "Parameter_Became_Non_VaList";
14484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($New_Value eq "..." and $Old_Value ne "...")
14486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # change from "int" to "..."
14487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ParamPos2==0)
14488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # ISO C requires a named argument before "..."
14489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
14490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $NewProblemType = "Parameter_Became_VaList";
14492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
144931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($Level eq "Binary" and ($SubProblemType eq "Parameter_Type_And_Size"
14494f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        or $SubProblemType eq "Parameter_Type" or $SubProblemType eq "Parameter_Type_Format"))
14495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($Arch1, $Arch2) = (getArch(1), getArch(2));
14497f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Arch1 eq "unknown"
14498f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            or $Arch2 eq "unknown")
14499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if one of the architectures is unknown
14500f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko              # then set other arhitecture to unknown too
14501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($Arch1, $Arch2) = ("unknown", "unknown");
14502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14503f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            my (%Conv1, %Conv2) = ();
14504fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($UseConv_Real{1}{"P"} and $UseConv_Real{2}{"P"})
14505f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # real
14506f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Real($CompleteSignature{1}{$Symbol}, $ParamPos1);
14507f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Real($CompleteSignature{2}{$Symbol}, $ParamPos2);
14508f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14509f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            else
14510f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            { # model
14511f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv1 = callingConvention_P_Model($CompleteSignature{1}{$Symbol}, $ParamPos1, $TypeInfo{1}, $Arch1, $OStarget, $WORD_SIZE{1});
14512f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                %Conv2 = callingConvention_P_Model($CompleteSignature{2}{$Symbol}, $ParamPos2, $TypeInfo{2}, $Arch2, $OStarget, $WORD_SIZE{2});
14513f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
14514f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Conv1{"Method"} eq $Conv2{"Method"})
14515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14516f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack")
14517f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14518f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Old_Size ne $New_Size) { # FIXME: isMemPadded, getOffset
14519f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Stack";
14520f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14522f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "reg")
14523f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                {
14524f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    if($Conv1{"Registers"} ne $Conv2{"Registers"}) {
14525f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        $NewProblemType = "Parameter_Type_And_Register";
14526f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    }
14527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14531f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                if($Conv1{"Method"} eq "stack") {
14532f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Stack_To_Register";
14533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14534f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                elsif($Conv1{"Method"} eq "register") {
14535f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                    $NewProblemType = "Parameter_Type_From_Register_To_Stack";
14536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14538f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"Old_Reg"} = $Conv1{"Registers"};
14539f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SubProblems{$SubProblemType}{"New_Reg"} = $Conv2{"Registers"};
14540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
145411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        %{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}=(
14542dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            "Target"=>$PName1,
14543f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            "Param_Pos"=>adjustParamPos($ParamPos1, $Symbol, 1),
145441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            "New_Signature"=>get_Signature($Symbol, 2) );
145451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        @{$CompatProblems{$Level}{$Symbol}{$NewProblemType}{$Parameter_Location}}{keys(%{$SubProblems{$SubProblemType}})} = values %{$SubProblems{$SubProblemType}};
14546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14547f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    @RecurTypes = ();
14549f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
14550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # checking type definition changes
14551f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Sub_SubProblems = mergeTypes($PType1_Id, $PType2_Id, $Level);
14552f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $SubProblemType (keys(%{$Sub_SubProblems}))
14553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14554f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $SubLocation (keys(%{$Sub_SubProblems->{$SubProblemType}}))
14555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewProblemType = $SubProblemType;
14557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SubProblemType eq "DataType_Size")
14558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14559f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($Type1{"Type"}!~/\A(Pointer|Ref)\Z/ and $SubLocation!~/\-\>/)
14560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # stack has been affected
14561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $NewProblemType = "DataType_Size_And_Stack";
14562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $NewLocation = ($SubLocation)?$Parameter_Location."->".$SubLocation:$Parameter_Location;
14565f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $CompatProblems{$Level}{$Symbol}{$NewProblemType}{$NewLocation} = $Sub_SubProblems->{$SubProblemType}{$SubLocation};
14566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byName($$$)
14571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
145731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
145751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"name"} eq $Name)
14577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $ParamPos;
14579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "lost";
14582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_ParamPair_Pos_byTypeAndPos($$$$$)
14585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
145861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TypeName, $MediumPos, $Order, $Symbol, $LibVersion) = @_;
14587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Positions = ();
145881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $ParamPos (sort {int($a)<=>int($b)} keys(%{$CompleteSignature{$LibVersion}{$Symbol}{"Param"}}))
14589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "backward" and $ParamPos>$MediumPos);
14591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Order eq "forward" and $ParamPos<$MediumPos);
145921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        next if(not defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos});
145931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $PTypeId = $CompleteSignature{$LibVersion}{$Symbol}{"Param"}{$ParamPos}{"type"};
1459462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($TypeInfo{$LibVersion}{$PTypeId}{"Name"} eq $TypeName) {
14595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Positions, $ParamPos);
14596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Positions;
14599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getTypeIdByName($$)
14602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14603e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    my ($TypeName, $LibVersion) = @_;
14604e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    return $TName_Tid{$LibVersion}{formatName($TypeName, "T")};
14605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
146078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes($$$)
146088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
146098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]}) {
146108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return $Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]};
146118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
146128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(isRecurType($_[0], $_[1], \@RecurTypes_Diff))
146138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # skip recursive declarations
146148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
146158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
146168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pushType($_[0], $_[1], \@RecurTypes_Diff);
146188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Diff = diffTypes_I(@_);
146198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    pop(@RecurTypes_Diff);
146208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return ($Cache{"diffTypes"}{$_[2]}{$_[0]}{$_[1]} = $Diff);
146228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
146238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
146248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub diffTypes_I($$$)
14625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
146261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Level) = @_;
146278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14628f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14629f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
146308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"} eq $Type2_Pure{"Name"})
14632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # equal types
14633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
146359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Type1_Pure{"Name"} eq "void")
146369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # from void* to something
146379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return 0;
146389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
14639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Pure{"Name"}=~/\*/
14640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Type2_Pure{"Name"}=~/\*/)
14641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # compared in detectTypeChange()
14642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
14643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
146448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
14645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %FloatType = map {$_=>1} (
14646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "float",
14647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "double",
14648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "long double"
14649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
14650fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14651fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T1 = $Type1_Pure{"Type"};
14652fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $T2 = $Type2_Pure{"Type"};
14653fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14654fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Struct"
14655fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Class")
14656fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14657fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T2 = "Struct";
14658fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14659fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14660fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 eq "Class"
14661fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and $T2 eq "Struct")
14662fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # compare as data structures
14663fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $T1 = "Struct";
14664fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
14665fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
14666fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($T1 ne $T2)
14667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different types
14668fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic"
14669fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T2 eq "Enum")
14670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "int" to "enum"
14671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14673fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T2 eq "Intrinsic"
14674fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        and $T1 eq "Enum")
14675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # "enum" to "int"
14676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
14679fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # union to struct
14680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          #  ...
14681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
14682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
14685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14686fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($T1 eq "Intrinsic")
14687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($FloatType{$Type1_Pure{"Name"}}
14689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or $FloatType{$Type2_Pure{"Name"}})
14690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "float" to "double"
14691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # "float" to "int"
146921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source")
146931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # Safe
146941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 0;
146951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
146961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
146971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    return 1;
146981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14701fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($T1=~/Class|Struct|Union|Enum/)
14702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs1 = keys(%{$Type1_Pure{"Memb"}});
14704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @Membs2 = keys(%{$Type2_Pure{"Memb"}});
14705fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not @Membs1
14706fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            or not @Membs2)
14707570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # private
14708570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                return 0;
14709570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
14710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($#Membs1!=$#Membs2)
14711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # different number of elements
14712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 1;
14713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14714fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($T1 eq "Enum")
14715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
14717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # compare elements by name and value
14718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"}
14719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    or $Type1_Pure{"Memb"}{$Pos}{"value"} ne $Type2_Pure{"Memb"}{$Pos}{"value"})
14720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # different names
14721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        return 1;
14722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Pos (@Membs1)
147288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
147291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Level eq "Source")
147301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    {
147311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Type1_Pure{"Memb"}{$Pos}{"name"} ne $Type2_Pure{"Memb"}{$Pos}{"name"})
147321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        { # different names
147331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            return 1;
147341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        }
147351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    }
147368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT1 = %{$TypeInfo{1}{$Type1_Pure{"Memb"}{$Pos}{"type"}}};
147388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my %MT2 = %{$TypeInfo{2}{$Type2_Pure{"Memb"}{$Pos}{"type"}}};
147398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if($MT1{"Name"} ne $MT2{"Name"}
147418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    or isAnon($MT1{"Name"}) or isAnon($MT2{"Name"}))
147428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    {
147438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL1 = get_PLevel($MT1{"Tid"}, 1);
147448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my $PL2 = get_PLevel($MT2{"Tid"}, 2);
147458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if($PL1 ne $PL2)
147478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different pointer level
147488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        # compare base types
147528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT1 = get_BaseType($MT1{"Tid"}, 1);
147538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        my %BT2 = get_BaseType($MT2{"Tid"}, 2);
147548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
147558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        if(diffTypes($BT1{"Tid"}, $BT2{"Tid"}, $Level))
147568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        { # different types
147578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                            return 1;
147588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                        }
147598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    }
14760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
147638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
147648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
147658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            # TODO: arrays, etc.
147668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
14767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
14769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
147711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub detectTypeChange($$$$)
14772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
147731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Type1_Id, $Type2_Id, $Prefix, $Level) = @_;
14774dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $Type1_Id or not $Type2_Id) {
14775dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return ();
14776dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
14777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LocalProblems = ();
1477862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($Type1_Id, 1);
1477962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type2 = get_Type($Type2_Id, 2);
14780f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Pure = get_PureType($Type1_Id, $TypeInfo{1});
14781f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Pure = get_PureType($Type2_Id, $TypeInfo{2});
14782f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type1_Base = ($Type1_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type1_Pure{"Tid"}, $TypeInfo{1}):get_BaseType($Type1_Id, 1);
14783f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my %Type2_Base = ($Type2_Pure{"Type"} eq "Array")?get_OneStep_BaseType($Type2_Pure{"Tid"}, $TypeInfo{2}):get_BaseType($Type2_Id, 2);
1478474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1478562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type1_PLevel = get_PLevel($Type1_Id, 1);
1478662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Type2_PLevel = get_PLevel($Type2_Id, 2);
14787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1{"Name"} or not $Type2{"Name"});
14788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Type1_Base{"Name"} or not $Type2_Base{"Name"});
14789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if($Type1_PLevel eq "" or $Type2_PLevel eq "");
14790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_Base{"Name"} ne $Type2_Base{"Name"}
14791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and ($Type1{"Name"} eq $Type2{"Name"} or ($Type1_PLevel>=1 and $Type1_PLevel==$Type2_PLevel
14792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Type1_Base{"Name"} ne "void" and $Type2_Base{"Name"} ne "void")))
14793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base type change
147949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Type1{"Name"} eq $Type2{"Name"})
147959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
147969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Type1{"Type"} eq "Typedef" and $Type2{"Type"} eq "Typedef")
147979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # will be reported in mergeTypes() as typedef problem
147989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return ();
147999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
148009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_1 = goToFirst($Type1{"Tid"}, 1, "Typedef");
148019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            my %Typedef_2 = goToFirst($Type2{"Tid"}, 2, "Typedef");
148029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(%Typedef_1 and %Typedef_2)
148039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
148049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Typedef_1{"Name"} eq $Typedef_2{"Name"}
148059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                and $Typedef_1{"Type"} eq "Typedef" and $Typedef_2{"Type"} eq "Typedef")
148069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # const Typedef
148079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    return ();
148089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
148099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
14810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1_Base{"Name"}!~/anon\-/ and $Type2_Base{"Name"}!~/anon\-/)
14812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
148131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary"
148148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} and $Type2_Base{"Size"}
148158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            and $Type1_Base{"Size"} ne $Type2_Base{"Size"})
14816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{$Prefix."_BaseType_And_Size"}}=(
14818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_Base{"Name"},
14819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_Base{"Name"},
14820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14821f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(diffTypes($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Level))
14826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # format change
14827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType_Format"}}=(
14828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14830f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14831f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                elsif(tNameLock($Type1_Base{"Tid"}, $Type2_Base{"Tid"}))
14834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_BaseType"}}=(
14836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1_Base{"Name"},
14837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2_Base{"Name"},
14838f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                        "Old_Size"=>$Type1_Base{"Size"}*$BYTE_SIZE,
14839f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2_Base{"Size"}*$BYTE_SIZE);
14840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Type1{"Name"} ne $Type2{"Name"})
14845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # type change
14846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"}!~/anon\-/ and $Type2{"Name"}!~/anon\-/)
14847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14848f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Prefix eq "Return"
14849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type1_Pure{"Name"} eq "void")
14850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_From_Void"}}=(
14852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2{"Name"},
14853f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Prefix eq "Return"
14856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $Type2_Pure{"Name"} eq "void")
14857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
14858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                %{$LocalProblems{"Return_Type_Became_Void"}}=(
14859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1{"Name"},
14860f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE);
14861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
14863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
148641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary"
14865dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} and $Type2{"Size"}
14866dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                and $Type1{"Size"} ne $Type2{"Size"})
14867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
14868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_Type_And_Size"}}=(
14869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Value"=>$Type1{"Name"},
14870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "New_Value"=>$Type2{"Name"},
14871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14872f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else
14875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
148768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    if(diffTypes($Type1_Id, $Type2_Id, $Level))
14877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # format change
14878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type_Format"}}=(
14879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14881f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14882f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    elsif(tNameLock($Type1_Id, $Type2_Id))
14885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # FIXME: correct this condition
14886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        %{$LocalProblems{$Prefix."_Type"}}=(
14887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "Old_Value"=>$Type1{"Name"},
14888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            "New_Value"=>$Type2{"Name"},
14889f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                            "Old_Size"=>$Type1{"Size"}*$BYTE_SIZE,
14890f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            "New_Size"=>$Type2{"Size"}*$BYTE_SIZE);
14891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
14892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
14893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type1_PLevel!=$Type2_PLevel)
14897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
14898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type1{"Name"} ne "void" and $Type1{"Name"} ne "..."
14899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Type2{"Name"} ne "void" and $Type2{"Name"} ne "...")
14900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
149011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source")
149021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
149031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$LocalProblems{$Prefix."_PointerLevel"}}=(
14904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "Old_Value"=>$Type1_PLevel,
14905ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    "New_Value"=>$Type2_PLevel);
14906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
149071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
149081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
14909fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Type2_PLevel>$Type1_PLevel)
14910fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
149111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Increased"}}=(
149121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
149131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
149141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14915fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                else
14916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
149171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    %{$LocalProblems{$Prefix."_PointerLevel_Decreased"}}=(
149181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "Old_Value"=>$Type1_PLevel,
149191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        "New_Value"=>$Type2_PLevel);
149201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
14921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14924ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    if($Type1_Pure{"Type"} eq "Array"
14925ac687f969ca8bee69e9eb5e3267097f679cf283bAndrey Ponomarenko    and $Type1_Pure{"BaseType"})
14926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # base_type[N] -> base_type[N]
14927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # base_type: older_structure -> typedef to newer_structure
149281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my %SubProblems = detectTypeChange($Type1_Base{"Tid"}, $Type2_Base{"Tid"}, $Prefix, $Level);
14929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $SubProblemType (keys(%SubProblems))
14930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
14931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SubProblemType=~s/_Type/_BaseType/g;
14932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if(defined $LocalProblems{$SubProblemType});
14933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Attr (keys(%{$SubProblems{$SubProblemType}})) {
14934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $LocalProblems{$SubProblemType}{$Attr} = $SubProblems{$SubProblemType}{$Attr};
14935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
14936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
14938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %LocalProblems;
14939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
14940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
14941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub tNameLock($$)
14942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
14943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Tid1, $Tid2) = @_;
149440d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my $Changed = 0;
149450d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if(differentDumps("G"))
149460d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different GCC versions
149470d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        $Changed = 1;
149480d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    elsif(differentDumps("V"))
149500d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # different versions of ABI dumps
1495174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1495274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
149530d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # latest names update
149540d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.6: added restrict qualifier
149550d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko          # 2.13: added missed typedefs to qualified types
1495674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko          # 2.20: prefix for struct, union and enum types
149570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Changed = 1;
149580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    }
149608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN1 = $TypeInfo{1}{$Tid1}{"Name"};
149628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $TN2 = $TypeInfo{2}{$Tid2}{"Name"};
149638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
149640d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    if($Changed)
14965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # different formats
14966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UseOldDumps)
14967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old dumps
14968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
149700d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1497162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TT1 = $TypeInfo{1}{$Tid1}{"Type"};
1497262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TT2 = $TypeInfo{2}{$Tid2}{"Type"};
149730d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1497462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base1 = get_Type($Tid1, 1);
149750d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base1{"Type"} and $Base1{"Type"} eq "Typedef") {
14976f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base1 = get_OneStep_BaseType($Base1{"Tid"}, $TypeInfo{1});
14977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1497862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Base2 = get_Type($Tid2, 2);
149790d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        while(defined $Base2{"Type"} and $Base2{"Type"} eq "Typedef") {
14980f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            %Base2 = get_OneStep_BaseType($Base2{"Tid"}, $TypeInfo{2});
14981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
14982850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName1 = uncover_typedefs($Base1{"Name"}, 1);
14983850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $BName2 = uncover_typedefs($Base2{"Name"}, 2);
14984850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($BName1 eq $BName2)
14985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # equal base types
14986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 0;
14987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
149880d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1498962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.13")
1499062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.13"))
149910d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # broken array names in ABI dumps < 2.13
149920d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            if($TT1 eq "Array"
1499374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TT2 eq "Array") {
149940d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                return 0;
149950d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            }
149960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        }
149970d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
1499862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.6")
1499962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        or not checkDump(2, "2.6"))
150000d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # added restrict attribute in 2.6
1500162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($TN1!~/\brestrict\b/
1500274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            and $TN2=~/\brestrict\b/) {
1500374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                return 0;
1500474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1500574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
1500674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1500774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not checkDump(1, "2.20")
1500874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        or not checkDump(2, "2.20"))
1500974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # added restrict attribute in 2.6
1501074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/
1501174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            or $TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
15012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return 0;
15013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15015ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
150168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    else
150178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
150188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct {...} type_t
150198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        # typedef struct type_t {...} type_t
150208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN1, " ".$TN2)!=-1)
150218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
150228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN1=~/\A(struct|union|enum) \Q$TN2\E\Z/) {
150238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
150248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
150258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
150268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(index($TN2, " ".$TN1)!=-1)
150278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
150288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TN2=~/\A(struct|union|enum) \Q$TN1\E\Z/) {
150298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 0;
150308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
150318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
150328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
15033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
15034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub differentDumps($)
15037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
150381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Check = $_[0];
15039989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if(defined $Cache{"differentDumps"}{$Check}) {
15040989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return $Cache{"differentDumps"}{$Check};
15041989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    }
15042dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if($UsedDump{1}{"V"} and $UsedDump{2}{"V"})
150431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
15044dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "G")
15045dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15046dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(getGccVersion(1) ne getGccVersion(2))
15047dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different GCC versions
15048989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15049dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
150501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15051dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($Check eq "V")
15052dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        {
15053dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if(cmpVersions(formatVersion($UsedDump{1}{"V"}, 2),
15054dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            formatVersion($UsedDump{2}{"V"}, 2))!=0)
15055dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # different dump versions (skip micro version)
15056989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko                return ($Cache{"differentDumps"}{$Check}=1);
15057dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
150581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
15059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15060989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return ($Cache{"differentDumps"}{$Check}=0);
15061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub formatVersion($$)
15064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # cut off version digits
15065dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($V, $Digits) = @_;
15066dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my @Elems = split(/\./, $V);
15067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(".", splice(@Elems, 0, $Digits));
15068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub htmlSpecChars($)
15071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
150735c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
150745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
15075dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
15076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
15077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/</&lt;/g;
15078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\-\>/&#45;&gt;/g; # &minus;
15079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/>/&gt;/g;
150808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
150818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/([^ ]) ([^ ])/$1\@SP\@$2/g;
15082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/ /&#160;/g; # &nbsp;
150838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Str=~s/\@SP\@/ /g;
15084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\n/<br\/>/g;
15085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
15086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
15087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
150905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub xmlSpecChars($)
150915c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
150925c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $Str = $_[0];
150935c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not $Str) {
150945c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return $Str;
150955c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
150965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
150975c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\&([^#]|\Z)/&amp;$1/g;
150985c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/</&lt;/g;
150995c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/>/&gt;/g;
151005c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151015c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\"/&quot;/g;
151025c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    $Str=~s/\'/&#39;/g;
151035c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
151045c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return $Str;
151055c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
151065c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
1510701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenkosub xmlSpecChars_R($)
1510801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko{
1510901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Str = $_[0];
1511001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Str) {
1511101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        return $Str;
1511201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    }
1511301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1511401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&amp;/&/g;
1511501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&lt;/</g;
1511601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&gt;/>/g;
1511701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1511801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&quot;/"/g;
1511901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Str=~s/&#39;/'/g;
1512001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1512101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    return $Str;
1512201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko}
1512301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
15124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub black_name($)
15125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
15127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "<span class='iname_b'>".highLight_Signature($Name)."</span>";
15128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature($)
15131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 0, 0, 0);
15134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_Italic_Color($)
15137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Signature = $_[0];
15139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return highLight_Signature_PPos_Italic($Signature, "", 1, 1, 1);
15140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_symbol($)
15143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Symbol = $_[0];
15145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Spec, $Ver) = ($Symbol, "", "");
15146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Symbol=~/\A([^\@\$\?]+)([\@\$]+)([^\@\$]+)\Z/) {
15147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($Name, $Spec, $Ver) = ($1, $2, $3);
15148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Name, $Spec, $Ver);
15150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cut_f_attrs($)
15153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($_[0]=~s/(\))((| (const volatile|const|volatile))(| \[static\]))\Z/$1/) {
15155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
15156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
15158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub highLight_Signature_PPos_Italic($$$$$)
15161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15162dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my ($FullSignature, $Param_Pos, $ItalicParams, $ColorParams, $ShowReturn) = @_;
15163dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    $Param_Pos = "" if(not defined $Param_Pos);
15164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckObjectsOnly) {
15165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ItalicParams=$ColorParams=0;
15166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Signature, $VersionSpec, $SymbolVersion) = separate_symbol($FullSignature);
15168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Return = "";
15169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ShowRetVal and $Signature=~s/([^:]):([^:].+?)\Z/$1/g) {
15170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Return = $2;
15171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
151721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $SCenter = find_center($Signature, "(");
15173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SCenter)
151741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # global data
15175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Signature = htmlSpecChars($Signature);
151768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature=~s!(\[data\])!<span class='attr'>$1</span>!g;
151771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= (($SymbolVersion)?"<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>":"");
15178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Return and $ShowReturn) {
151791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Signature;
15182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Begin, $End) = (substr($Signature, 0, $SCenter), "");
15184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Begin.=" " if($Begin!~/ \Z/);
15185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $End = cut_f_attrs($Signature);
15186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
1518707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Short, $Params) = split_Signature($Signature);
1518807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my @SParts = separate_Params($Params, 1, 1);
15189dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    foreach my $Pos (0 .. $#SParts)
15190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15191dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Part = $SParts[$Pos];
15192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part=~s/\A\s+|\s+\Z//g;
15193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($Part_Styled, $ParamName) = (htmlSpecChars($Part), "");
15194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Part=~/\([\*]+(\w+)\)/i) {
15195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;#func-ptr
15196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Part=~/(\w+)[\,\)]*\Z/i) {
15198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ParamName = $1;
15199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
152008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $ParamName)
152018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
15202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            push(@Parts, $Part_Styled);
15203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
15204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ItalicParams and not $TName_Tid{1}{$Part}
15206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $TName_Tid{2}{$Part})
15207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
152080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            my $Style = "param";
15209dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Param_Pos ne ""
15210dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            and $Pos==$Param_Pos) {
152110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "focus_p";
15212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($ColorParams) {
152140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                $Style = "color_p";
15215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
152160d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko            $Part_Styled =~ s!(\W)$ParamName([\,\)]|\Z)!$1<span class=\'$Style\'>$ParamName</span>$2!ig;
15217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Part_Styled=~s/,(\w)/, $1/g;
15219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Parts, $Part_Styled);
15220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@Parts)
15222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Num (0 .. $#Parts)
15224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Num==$#Parts)
15226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # add ")" to the last parameter
15227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]." )</span>";
15228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif(length($Parts[$Num])<=45) {
15230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Parts[$Num] = "<span class='nowrap'>".$Parts[$Num]."</span>";
15231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
152331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;".join(" ", @Parts)."</span>".$End;
15234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
152361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature = htmlSpecChars($Begin)."<span class='sym_p'>(&#160;)</span>".$End;
15237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Return and $ShowReturn) {
152391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Signature .= "<span class='sym_p nowrap'> &#160;<b>:</b>&#160;&#160;".htmlSpecChars($Return)."</span>";
15240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
152411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!\[\]![&#160;]!g;
152421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Signature=~s!operator=!operator&#160;=!g;
152438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $Signature=~s!(\[in-charge\]|\[not-in-charge\]|\[in-charge-deleting\]|\[static\])!<span class='attr'>$1</span>!g;
152448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($SymbolVersion) {
152458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Signature .= "<span class='sym_ver'>&#160;$VersionSpec&#160;$SymbolVersion</span>";
152468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
152478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return $Signature;
15248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1525007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub split_Signature($)
15251ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1525207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my $Signature = $_[0];
1525307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(my $ShortName = substr($Signature, 0, find_center($Signature, "(")))
1525407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
1525507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\A\Q$ShortName\E\(//g;
1525607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        cut_f_attrs($Signature);
1525707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Signature=~s/\)\Z//;
1525807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return ($ShortName, $Signature);
1525907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
1526007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1526107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # error
1526207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    return ($Signature, "");
15263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1526507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub separate_Params($$$)
15266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1526707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Params, $Comma, $Sp) = @_;
15268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Parts = ();
152691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
152701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $Part = 0;
15271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Params) - 1)
15272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
152731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $S = substr($Params, $Pos, 1);
152741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $B{$S}) {
1527507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $B{$S} += 1;
152761693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
152771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($S eq "," and
152781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $B{"("}==$B{")"} and $B{"<"}==$B{">"})
15279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
152801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Comma)
152811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            { # include comma
152821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Parts[$Part] .= $S;
15283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
152841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Part += 1;
15285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
152871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Parts[$Part] .= $S;
15288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1529007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(not $Sp)
1529107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    { # remove spaces
1529207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        foreach (@Parts)
1529307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1529407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/\A //g;
1529507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            s/ \Z//g;
1529607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1529707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
15298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Parts;
15299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
153011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub find_center($$)
15302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Sign, $Target) = @_;
153041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %B = ( "("=>0, "<"=>0, ")"=>0, ">"=>0 );
15305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Center = 0;
153061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Sign=~s/(operator([^\w\s\(\)]+|\(\)))//g)
153071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # operators
15308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=length($1);
15309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (0 .. length($Sign)-1)
15311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $S = substr($Sign, $Pos, 1);
15313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S eq $Target)
15314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($B{"("}==$B{")"}
15316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and $B{"<"}==$B{">"}) {
15317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $Center;
15318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $B{$S}) {
15321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $B{$S}+=1;
15322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Center+=1;
15324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
15326ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15328ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub appendFile($$)
15329ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15330ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15331ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15332ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">>", $Path) || die ("can't open file \'$Path\': $!\n");
15336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeFile($$)
15341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Content) = @_;
15343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $Path);
15344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Dir = get_dirname($Path)) {
15345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($Dir);
15346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
153471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, ">", $Path) || die ("can't open file \'$Path\': $!\n");
15348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    print FILE $Content;
15349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readFile($)
15353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
153561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    local $/ = undef;
15358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = <FILE>;
15359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15360850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($Path!~/\.(tu|class|abi)\Z/) {
15361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\r/\n/g;
15362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
15364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_filename($)
15367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than basename() from File::Basename module
15368850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_filename"}{$_[0]}) {
15369850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_filename"}{$_[0]};
15370850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
153711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/([^\/\\]+)[\/\\]*\Z/) {
15372850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_filename"}{$_[0]}=$1);
15373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15374850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_filename"}{$_[0]}="");
15375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dirname($)
15378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # much faster than dirname() from File::Basename module
15379850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(defined $Cache{"get_dirname"}{$_[0]}) {
15380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return $Cache{"get_dirname"}{$_[0]};
15381850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
153821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($_[0] and $_[0]=~/\A(.*?)[\/\\]+[^\/\\]*[\/\\]*\Z/) {
15383850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        return ($Cache{"get_dirname"}{$_[0]}=$1);
15384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15385850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return ($Cache{"get_dirname"}{$_[0]}="");
15386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15388ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub separate_path($) {
15389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return (get_dirname($_[0]), get_filename($_[0]));
15390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub esc($)
15393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
15395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/([()\[\]{}$ &'"`;,<>\+])/\\$1/g;
15396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Str;
15397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLineNum($$)
15400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Num) = @_;
15402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Path or not -f $Path);
154031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    open(FILE, $Path);
15404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (1 ... $Num) {
15405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        <FILE>;
15406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Line = <FILE>;
15408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(FILE);
15409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Line;
15410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
154120d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenkosub readAttributes($$)
15413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
154140d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    my ($Path, $Num) = @_;
15415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $Path or not -f $Path);
15416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Attributes = ();
15417850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(readLineNum($Path, $Num)=~/<!--\s+(.+)\s+-->/)
15418850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15419850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $AttrVal (split(/;/, $1))
15420850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($AttrVal=~/(.+):(.+)/)
15422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
15424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Attributes{$Name} = $Value;
15425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Attributes;
15429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_abs($) {
15432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($_[0]=~/\A(\/|\w+:[\/\\])/);
15433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_abs_path($)
15436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # abs_path() should NOT be called for absolute inputs
15437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # because it can change them
15438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
15439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not is_abs($Path)) {
15440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = abs_path($Path);
15441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Path;
15443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_OSgroup()
15446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15447f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    my $N = $Config{"osname"};
15448f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    if($N=~/macos|darwin|rhapsody/i) {
15449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "macos";
15450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15451f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/freebsd|openbsd|netbsd/i) {
15452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "bsd";
15453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15454f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/haiku|beos/i) {
15455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "beos";
15456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15457f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/symbian|epoc/i) {
15458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "symbian";
15459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15460f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    elsif($N=~/win/i) {
15461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "windows";
15462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
15464f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        return $N;
15465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getGccVersion($)
15469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GCC_VERSION{$LibVersion})
15472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $GCC_VERSION{$LibVersion};
15474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $GccVersion = get_dumpversion($GCC_PATH); # host version
15480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $GccVersion) {
15481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $GccVersion;
15484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showArch($)
15487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = $_[0];
15489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch eq "arm"
15490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Arch eq "mips") {
15491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return uc($Arch);
15492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getArch($)
15497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
15499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CPU_ARCH{$LibVersion})
15500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dump version
15501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $CPU_ARCH{$LibVersion};
15502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($UsedDump{$LibVersion}{"V"})
15504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old-version dumps
15505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"getArch"}{$LibVersion}) {
15508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"getArch"}{$LibVersion};
15509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Arch = get_dumpmachine($GCC_PATH); # host version
15511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Arch) {
15512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "unknown";
15513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Arch=~/\A([\w]{3,})(-|\Z)/) {
15515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Arch = $1;
15516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15517177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $Arch = "x86" if($Arch=~/\Ai[3-7]86\Z/i);
15518177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    $Arch = "x86_64" if($Arch=~/\Aamd64\Z/i);
15519c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko    if($OSgroup eq "windows")
15520c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko    {
15521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Arch = "x86" if($Arch=~/win32|mingw32/i);
15522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Arch = "x86_64" if($Arch=~/win64|mingw64/i);
15523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Cache{"getArch"}{$LibVersion} = $Arch;
15525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Arch;
15526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
155281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_Header($)
15529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
155301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
15531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $ArchInfo = " on <span style='color:Blue;'>".showArch(getArch(1))."</span>";
155321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(getArch(1) ne getArch(2)
155331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or getArch(1) eq "unknown"
155341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
15535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # don't show architecture in the header
15536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ArchInfo="";
15537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
155381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Report_Header = "<h1><span class='nowrap'>";
155391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Source") {
155401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report_Header .= "Source compatibility";
155411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Binary") {
155431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report_Header .= "Binary compatibility";
155441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
155461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report_Header .= "API compatibility";
155471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
155481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Report_Header .= " report for the <span style='color:Blue;'>$TargetLibraryFName</span> $TargetComponent</span>";
15549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report_Header .= " <span class='nowrap'>&#160;between <span style='color:Red;'>".$Descriptor{1}{"Version"}."</span> and <span style='color:Red;'>".$Descriptor{2}{"Version"}."</span> versions$ArchInfo</span>";
15550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath) {
15551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report_Header .= " <span class='nowrap'>&#160;(relating to the portability of application <span style='color:Blue;'>".get_filename($AppPath)."</span>)</span>";
15552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report_Header .= "</h1>\n";
15554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report_Header;
15555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_SourceInfo()
15558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15559fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($CheckedHeaders, $CheckedSources, $CheckedLibs) = ("", "");
1556062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckObjectsOnly)
15561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15562fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
1556362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
15564fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders = "<a name='Headers'></a><h2>Header Files (".($#Headers+1).")</h2><hr/>\n";
15565fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders .= "<div class='h_list'>\n";
15566fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Header_Path (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15567fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15568fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Header_Path}{"Identity"};
15569fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Name = get_filename($Identity);
15570fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15571fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CheckedHeaders .= $Name.$Comment."<br/>\n";
15572fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15573fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders .= "</div>\n";
15574fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedHeaders .= "<br/>$TOP_REF<br/>\n";
15575fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15576fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15577fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15578fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15579fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources = "<a name='Sources'></a><h2>Source Files (".($#Sources+1).")</h2><hr/>\n";
15580fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources .= "<div class='h_list'>\n";
15581fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Header_Path (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15582fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15583fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Header_Path}{"Identity"};
15584fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Name = get_filename($Identity);
15585fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15586fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $CheckedSources .= $Name.$Comment."<br/>\n";
15587fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15588fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources .= "</div>\n";
15589fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $CheckedSources .= "<br/>$TOP_REF<br/>\n";
1559062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
15591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1559262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $CheckHeadersOnly)
15593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15594fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $CheckedLibs = "<a name='Libs'></a><h2>".get_ObjTitle()." (".keys(%{$Library_Symbol{1}}).")</h2><hr/>\n";
1559562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<div class='lib_list'>\n";
1559662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
1559762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1559862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
1559962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $CheckedLibs .= $Library."<br/>\n";
1560062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1560162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "</div>\n";
1560262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $CheckedLibs .= "<br/>$TOP_REF<br/>\n";
15603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15604fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $CheckedHeaders.$CheckedSources.$CheckedLibs;
15605fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
15606fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15607fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub get_ObjTitle()
15608fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
15609fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $UsedDump{1}{"DWARF"}) {
15610fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return "Objects";
15611fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15612fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else {
15613fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return ucfirst($SLIB_TYPE)." Libraries";
15614fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
15615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_TypeProblems_Count($$$)
15618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
15619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TypeChanges, $TargetPriority, $Level) = @_;
15620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Type_Problems_Count = 0;
15621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type_Name (sort keys(%{$TypeChanges}))
15622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
15623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my %Kinds_Target = ();
15624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (keys(%{$TypeChanges->{$Type_Name}}))
15625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Location (keys(%{$TypeChanges->{$Type_Name}{$Kind}}))
15627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges->{$Type_Name}{$Kind}{$Location}{"Target"};
156292489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
156302489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next if($Severity ne $TargetPriority);
15631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Kinds_Target{$Kind}{$Target}) {
15632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
15633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
156342489ef88760861175102e4508089608391beead3Andrey Ponomarenko
156352489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target})
156362489ef88760861175102e4508089608391beead3Andrey Ponomarenko                {
156372489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
156382489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    { # select a problem with the highest priority
156392489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        next;
156402489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    }
15641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Target{$Kind}{$Target} = 1;
15643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Type_Problems_Count += 1;
15644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Type_Problems_Count;
15648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
15649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Summary($)
15651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
156521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
156531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Added, $Removed, $I_Problems_High, $I_Problems_Medium, $I_Problems_Low, $T_Problems_High,
156548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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);
156551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %{$RESULT{$Level}} = (
156561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Problems"=>0,
156571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Warnings"=>0,
156581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        "Affected"=>0 );
15659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check rules
156601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
15665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # unknown rule
15666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
15667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # only one warning
15668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
15669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
15670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
156711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                delete($CompatProblems{$Level}{$Interface}{$Kind});
15672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
156758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (sort keys(%{$CompatProblems_Constants{$Level}}))
156768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
156778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
156788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
156798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind})
156808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # unknown rule
156818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(not $UnknownRules{$Level}{$Kind})
156828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # only one warning
156838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    printMsg("WARNING", "unknown rule \"$Kind\" (\"$Level\")");
156848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $UnknownRules{$Level}{$Kind}=1;
156858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
156868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                delete($CompatProblems_Constants{$Level}{$Constant}{$Kind});
156878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
156888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
156898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
156901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
156921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
15693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols")
15695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
156961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
156982489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
156991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Kind eq "Added_Symbol") {
15700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added += 1;
15701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
157021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    elsif($Kind eq "Removed_Symbol")
15703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
15704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed += 1;
157052489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $TotalAffected{$Level}{$Interface} = $Severity;
15706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
15708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
157092489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity eq "Safe") {
15710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Other += 1;
15711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157122489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "High") {
15713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_High += 1;
15714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157152489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Medium") {
15716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Medium += 1;
15717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157182489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        elsif($Severity eq "Low") {
15719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $I_Problems_Low += 1;
15720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
157212489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if(($Severity ne "Low" or $StrictCompat)
157222489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        and $Severity ne "Safe") {
157232489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
15725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %TypeChanges = ();
157311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
15732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
157331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
15734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
15736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
15737f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
15738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
157391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Type_Name = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
157401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
157412489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
15742f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $MaxSeverity = $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target};
15743f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
157442489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($MaxSeverity and $Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
15745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    { # select a problem with the highest priority
15746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
15747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15748f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
157492489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(($Severity ne "Low" or $StrictCompat)
157502489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    and $Severity ne "Safe")
15751f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
15752f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        if(defined $TotalAffected{$Level}{$Interface})
15753f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        {
157542489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            if($Severity_Val{$Severity}>$Severity_Val{$TotalAffected{$Level}{$Interface}}) {
157552489ef88760861175102e4508089608391beead3Andrey Ponomarenko                                $TotalAffected{$Level}{$Interface} = $Severity;
15756f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                            }
15757f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15758f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        else {
157592489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $TotalAffected{$Level}{$Interface} = $Severity;
15760f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15761f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15762f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15763f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeChanges{$Type_Name}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
15764f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15765f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($MaxSeverity)
15766f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    {
157672489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$Severity}>$Severity_Val{$MaxSeverity}) {
157682489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15769f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        }
15770f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    }
15771f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    else {
157722489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        $Type_MaxSeverity{$Level}{$Type_Name}{$Kind}{$Target} = $Severity;
15773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
15774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
15775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
157781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_High = get_TypeProblems_Count(\%TypeChanges, "High", $Level);
15780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Medium = get_TypeProblems_Count(\%TypeChanges, "Medium", $Level);
15781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Problems_Low = get_TypeProblems_Count(\%TypeChanges, "Low", $Level);
15782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $T_Other = get_TypeProblems_Count(\%TypeChanges, "Safe", $Level);
157831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
15784f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    %TypeChanges = (); # free memory
15785f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
15786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckObjectsOnly)
15787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # only removed exported symbols
157881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = $Removed*100/keys(%{$Symbol_Library{1}});
15789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
15791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # changed and removed public symbols
157921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $SCount = keys(%{$CheckedSymbols{$Level}});
15793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck)
15794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # don't count external_func_0 for constants
15795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SCount-=1;
15796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SCount)
15798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Weight = (
15800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "High" => 100,
15801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Medium" => 50,
15802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Low" => 25
15803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            );
15804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach (keys(%{$TotalAffected{$Level}})) {
158051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $RESULT{$Level}{"Affected"}+=$Weight{$TotalAffected{$Level}{$_}};
15806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
158071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RESULT{$Level}{"Affected"} = $RESULT{$Level}{"Affected"}/$SCount;
15808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
158101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $RESULT{$Level}{"Affected"} = 0;
15811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
158131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Affected"} = show_number($RESULT{$Level}{"Affected"});
158141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($RESULT{$Level}{"Affected"}>=100) {
158151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $RESULT{$Level}{"Affected"} = 100;
15816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15818850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $Removed;
15819850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_High + $I_Problems_High;
158201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $RESULT{$Level}{"Problems"} += $T_Problems_Medium + $I_Problems_Medium;
15821850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($StrictCompat) {
15822850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Problems"} += $T_Problems_Low + $I_Problems_Low;
15823850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15824850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15825850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Warnings"} += $T_Problems_Low + $I_Problems_Low;
15826850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
158288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
158291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
158308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
15831850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        {
15832f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
158338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Severity eq "Safe")
158348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
158358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Other+=1;
15836850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
158378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            elsif($Severity eq "Low")
158388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
158398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $C_Problems_Low+=1;
15840850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
158411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
158428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
158438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
158448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($C_Problems_Low)
158458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
158468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($StrictCompat) {
158478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += $C_Problems_Low;
158488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
158498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else {
158508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += $C_Problems_Low;
158511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
158521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
15853850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($CheckImpl and $Level eq "Binary")
15854850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    {
15855850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($StrictCompat) {
158568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Problems"} += keys(%CompatProblems_Impl);
15857850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
15858850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        else {
158598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $RESULT{$Level}{"Warnings"} += keys(%CompatProblems_Impl);
15860850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
15861850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15862850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($RESULT{$Level}{"Problems"}
15863850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    and $RESULT{$Level}{"Affected"}) {
15864850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "incompatible";
15865850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
15866850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    else {
15867850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $RESULT{$Level}{"Verdict"} = "compatible";
158681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
158691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
158701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $TotalTypes = keys(%{$CheckedTypes{$Level}});
158711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $TotalTypes)
158721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # list all the types
15873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TotalTypes = keys(%{$TName_Tid{1}});
15874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Arch1, $Arch2) = (getArch(1), getArch(2));
15877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($GccV1, $GccV2) = (getGccVersion(1), getGccVersion(2));
15878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($TestInfo, $TestResults, $Problem_Summary) = ();
15880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
15882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
15883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <library>$TargetLibraryName</library>\n";
15885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version1>\n";
15886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{1}{"Version"}."</number>\n";
15887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <architecture>$Arch1</architecture>\n";
15888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV1</gcc>\n";
15889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version1>\n";
15890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  <version2>\n";
15892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <number>".$Descriptor{2}{"Version"}."</number>\n";
15893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <architecture>$Arch2</architecture>\n";
15894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "    <gcc>$GccV2</gcc>\n";
15895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "  </version2>\n";
15896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<test_info>\n".$TestInfo."</test_info>\n\n";
15897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
15899fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
15900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15901fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <headers>\n";
15902fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Headers{1}{$a}{"Identity"}) cmp lc($Registered_Headers{1}{$b}{"Identity"})} @Headers)
15903fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15904fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Headers{1}{$Name}{"Identity"};
15905fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15906fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15907fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15908fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </headers>\n";
15909fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
15910fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
15911fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
15912fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
15913fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  <sources>\n";
15914fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Name (sort {lc($Registered_Sources{1}{$a}{"Identity"}) cmp lc($Registered_Sources{1}{$b}{"Identity"})} @Sources)
15915fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
15916fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Identity = $Registered_Sources{1}{$Name}{"Identity"};
15917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Comment = ($Identity=~/[\/\\]/)?" ($Identity)":"";
15918fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $TestResults .= "    <name>".get_filename($Name).$Comment."</name>\n";
15919fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
15920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "  </sources>\n";
15921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <libs>\n";
15924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Library (sort {lc($a) cmp lc($b)}  keys(%{$Library_Symbol{1}}))
15925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Library.=" (.$LIB_EXT)" if($Library!~/\.\w+\Z/);
15927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestResults .= "    <name>$Library</name>\n";
15928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  </libs>\n";
15930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1593162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "  <symbols>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))."</symbols>\n";
15932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "  <types>".$TotalTypes."</types>\n";
15933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
159341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <verdict>".$RESULT{$Level}{"Verdict"}."</verdict>\n";
159351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "  <affected>".$RESULT{$Level}{"Affected"}."</affected>\n";
15936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<test_results>\n".$TestResults."</test_results>\n\n";
15937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
15939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <added_symbols>".$Added."</added_symbols>\n";
15940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <removed_symbols>".$Removed."</removed_symbols>\n";
15941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_types>\n";
15943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$T_Problems_High</high>\n";
15944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$T_Problems_Medium</medium>\n";
15945ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$T_Problems_Low</low>\n";
15946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <safe>$T_Other</safe>\n";
15947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_types>\n";
15948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_symbols>\n";
15950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <high>$I_Problems_High</high>\n";
15951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <medium>$I_Problems_Medium</medium>\n";
15952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "    <low>$I_Problems_Low</low>\n";
159531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <safe>$I_Other</safe>\n";
15954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_symbols>\n";
15955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  <problems_with_constants>\n";
159571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "    <low>$C_Problems_Low</low>\n";
15958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "  </problems_with_constants>\n";
159591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CheckImpl and $Level eq "Binary")
15960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
15961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Problem_Summary .= "  <impl>\n";
159628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "    <low>".keys(%CompatProblems_Impl)."</low>\n";
15963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Problem_Summary .= "  </impl>\n";
15964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<problem_summary>\n".$Problem_Summary."</problem_summary>\n\n";
15966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, "");
15968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
15969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
15970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
15971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test info
15972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo = "<h2>Test Info</h2><hr/>\n";
159731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestInfo .= "<table class='summary'>\n";
15974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>".ucfirst($TargetComponent)." Name</th><td>$TargetLibraryFName</td></tr>\n";
15975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
15976ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my (@VInf1, @VInf2, $AddTestInfo) = ();
15977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Arch1 ne "unknown"
15978ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Arch2 ne "unknown")
15979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # CPU arch
15980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Arch1 eq $Arch2)
15981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
159821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $AddTestInfo .= "<tr><th>CPU Type</th><td>".showArch($Arch1)."</td></tr>\n";
15983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
15986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, showArch($Arch1));
15987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, showArch($Arch2));
15988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
15990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($GccV1 ne "unknown"
15991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $GccV2 ne "unknown"
15992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $OStarget ne "windows")
15993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # GCC version
15994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GccV1 eq $GccV2)
15995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the separate section
15996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $AddTestInfo .= "<tr><th>GCC Version</th><td>$GccV1</td></tr>\n";
15997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
15998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
15999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # go to the version number
16000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf1, "gcc ".$GccV1);
16001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@VInf2, "gcc ".$GccV2);
16002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # show long version names with GCC version and CPU architecture name (if different)
16005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #1</th><td>".$Descriptor{1}{"Version"}.(@VInf1?" (".join(", ", reverse(@VInf1)).")":"")."</td></tr>\n";
16006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "<tr><th>Version #2</th><td>".$Descriptor{2}{"Version"}.(@VInf2?" (".join(", ", reverse(@VInf2)).")":"")."</td></tr>\n";
16007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= $AddTestInfo;
16008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #if($COMMON_LANGUAGE{1}) {
16009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #    $TestInfo .= "<tr><th>Language</th><td>".$COMMON_LANGUAGE{1}."</td></tr>\n";
16010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        #}
16011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ExtendedCheck) {
16012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TestInfo .= "<tr><th>Mode</th><td>Extended</td></tr>\n";
16013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
160141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
160151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary") {
160171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Binary Compatibility</td></tr>\n"; # Run-time
160181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Source") {
160201693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $TestInfo .= "<tr><th>Subject</th><td width='150px'>Source Compatibility</td></tr>\n"; # Build-time
160211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestInfo .= "</table>\n";
16024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # test results
16026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults = "<h2>Test Results</h2><hr/>\n";
160271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TestResults .= "<table class='summary'>";
16028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16029fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Headers = keys(%{$Registered_Headers{1}}))
16030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Headers_Link = "<a href='#Headers' style='color:Blue;'>".($#Headers + 1)."</a>";
16032fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>".$Headers_Link."</td></tr>\n";
16033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16034fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif($CheckObjectsOnly) {
16035fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Header Files</th><td>0&#160;(not&#160;analyzed)</td></tr>\n";
16036fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16037fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
16038fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my @Sources = keys(%{$Registered_Sources{1}}))
16039fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
16040fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Src_Link = "<a href='#Sources' style='color:Blue;'>".($#Sources + 1)."</a>";
16041fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total Source Files</th><td>".$Src_Link."</td></tr>\n";
16042fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
16043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck)
16045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Libs_Link = "0";
16047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Libs_Link = "<a href='#Libs' style='color:Blue;'>".keys(%{$Library_Symbol{1}})."</a>" if(keys(%{$Library_Symbol{1}})>0);
16048fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TestResults .= "<tr><th>Total ".get_ObjTitle()."</th><td>".($CheckHeadersOnly?"0&#160;(not&#160;analyzed)":$Libs_Link)."</td></tr>\n";
16049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1605162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $TestResults .= "<tr><th>Total Symbols / Types</th><td>".(keys(%{$CheckedSymbols{$Level}}) - keys(%ExtendedSymbols))." / ".$TotalTypes."</td></tr>\n";
16052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16053850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $META_DATA = "verdict:".$RESULT{$Level}{"Verdict"}.";";
160541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport) {
160551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $META_DATA = "kind:".lc($Level).";".$META_DATA;
160561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
160571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "<tr><th>Verdict</th>";
16058850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($RESULT{$Level}{"Verdict"} eq "incompatible") {
160591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Red;'><b>Incompatible<br/>(".$RESULT{$Level}{"Affected"}."%)</b></span></td>";
160601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
160611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else {
160621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $TestResults .= "<td><span style='color:Green;'><b>Compatible</b></span></td>";
160631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
160641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $TestResults .= "</tr>\n";
16065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestResults .= "</table>\n";
16066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
160671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "affected:".$RESULT{$Level}{"Affected"}.";";# in percents
16068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # problem summary
16069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary = "<h2>Problem Summary</h2><hr/>\n";
160701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Problem_Summary .= "<table class='summary'>";
16071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "<tr><th></th><th style='text-align:center;'>Severity</th><th style='text-align:center;'>Count</th></tr>";
16072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Link = "0";
160741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Added>0)
160751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
160771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#".$Level."_Added' style='color:Blue;'>$Added</a>";
160781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
160801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Added_Link = "<a href='#Added' style='color:Blue;'>$Added</a>";
160811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "added:$Added;";
160841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Added Symbols</th><td>-</td><td".getStyle("I", "A", $Added).">$Added_Link</td></tr>\n";
16085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Removed_Link = "0";
160871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Removed>0)
160881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
160891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
160901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#".$Level."_Removed' style='color:Blue;'>$Removed</a>"
160911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else {
160931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Removed_Link = "<a href='#Removed' style='color:Blue;'>$Removed</a>"
160941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
160951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "removed:$Removed;";
160971693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th>Removed Symbols</th>";
160981693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "R", $Removed).">$Removed_Link</td></tr>\n";
16099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TH_Link = "0";
161011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TH_Link = "<a href='#".get_Anchor("Type", $Level, "High")."' style='color:Blue;'>$T_Problems_High</a>" if($T_Problems_High>0);
16102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TH_Link = "n/a" if($CheckObjectsOnly);
16103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_high:$T_Problems_High;";
161041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Data Types</th>";
161051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("T", "H", $T_Problems_High).">$TH_Link</td></tr>\n";
16106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TM_Link = "0";
161081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TM_Link = "<a href='#".get_Anchor("Type", $Level, "Medium")."' style='color:Blue;'>$T_Problems_Medium</a>" if($T_Problems_Medium>0);
16109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TM_Link = "n/a" if($CheckObjectsOnly);
16110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_medium:$T_Problems_Medium;";
161111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("T", "M", $T_Problems_Medium).">$TM_Link</td></tr>\n";
16112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TL_Link = "0";
161141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TL_Link = "<a href='#".get_Anchor("Type", $Level, "Low")."' style='color:Blue;'>$T_Problems_Low</a>" if($T_Problems_Low>0);
16115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TL_Link = "n/a" if($CheckObjectsOnly);
16116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "type_problems_low:$T_Problems_Low;";
161171693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("T", "L", $T_Problems_Low).">$TL_Link</td></tr>\n";
16118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IH_Link = "0";
161201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IH_Link = "<a href='#".get_Anchor("Symbol", $Level, "High")."' style='color:Blue;'>$I_Problems_High</a>" if($I_Problems_High>0);
16121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IH_Link = "n/a" if($CheckObjectsOnly);
16122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_high:$I_Problems_High;";
161231693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><th rowspan='3'>Problems with<br/>Symbols</th>";
161241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<td>High</td><td".getStyle("I", "H", $I_Problems_High).">$IH_Link</td></tr>\n";
16125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IM_Link = "0";
161271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IM_Link = "<a href='#".get_Anchor("Symbol", $Level, "Medium")."' style='color:Blue;'>$I_Problems_Medium</a>" if($I_Problems_Medium>0);
16128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IM_Link = "n/a" if($CheckObjectsOnly);
16129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_medium:$I_Problems_Medium;";
161301693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Medium</td><td".getStyle("I", "M", $I_Problems_Medium).">$IM_Link</td></tr>\n";
16131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $IL_Link = "0";
161331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $IL_Link = "<a href='#".get_Anchor("Symbol", $Level, "Low")."' style='color:Blue;'>$I_Problems_Low</a>" if($I_Problems_Low>0);
16134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $IL_Link = "n/a" if($CheckObjectsOnly);
16135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "interface_problems_low:$I_Problems_Low;";
161361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Problem_Summary .= "<tr><td>Low</td><td".getStyle("I", "L", $I_Problems_Low).">$IL_Link</td></tr>\n";
16137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ChangedConstants_Link = "0";
161398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}}) and $C_Problems_Low) {
161408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedConstants_Link = "<a href='#".get_Anchor("Constant", $Level, "Low")."' style='color:Blue;'>$C_Problems_Low</a>";
16141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ChangedConstants_Link = "n/a" if($CheckObjectsOnly);
161431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $META_DATA .= "changed_constants:$C_Problems_Low;";
161441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
16145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CheckImpl and $Level eq "Binary")
16147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $ChangedImpl_Link = "0";
161498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ChangedImpl_Link = "<a href='#Changed_Implementation' style='color:Blue;'>".keys(%CompatProblems_Impl)."</a>" if(keys(%CompatProblems_Impl)>0);
16150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ChangedImpl_Link = "n/a" if($CheckHeadersOnly);
161518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $META_DATA .= "changed_implementation:".keys(%CompatProblems_Impl).";";
161528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Problems with<br/>Implementation</th><td>Low</td><td".getStyle("Imp", "L", int(keys(%CompatProblems_Impl))).">$ChangedImpl_Link</td></tr>\n";
16153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # Safe Changes
161551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($T_Other and not $CheckObjectsOnly)
161561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $TS_Link = "<a href='#".get_Anchor("Type", $Level, "Safe")."' style='color:Blue;'>$T_Other</a>";
161581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey 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";
161591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
161601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
161611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($I_Other and not $CheckObjectsOnly)
161621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
161631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $IS_Link = "<a href='#".get_Anchor("Symbol", $Level, "Safe")."' style='color:Blue;'>$I_Other</a>";
161641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Symbols</th><td>-</td><td".getStyle("I", "S", $I_Other).">$IS_Link</td></tr>\n";
16165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($C_Other and not $CheckObjectsOnly)
161688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
161698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $CS_Link = "<a href='#".get_Anchor("Constant", $Level, "Safe")."' style='color:Blue;'>$C_Other</a>";
161708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Problem_Summary .= "<tr><th>Other Changes<br/>in Constants</th><td>-</td><td".getStyle("C", "S", $C_Other).">$CS_Link</td></tr>\n";
161718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
161728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $META_DATA .= "tool_version:$TOOL_VERSION";
16174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Problem_Summary .= "</table>\n";
161751693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # $TestInfo = getLegend().$TestInfo;
16176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($TestInfo.$TestResults.$Problem_Summary, $META_DATA);
16177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
161801693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getStyle($$$)
161811693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
161821693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Subj, $Act, $Num) = @_;
161831693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %Style = (
161841693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "A"=>"new",
161851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "R"=>"failed",
161861693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "S"=>"passed",
161871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "L"=>"warning",
161881693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "M"=>"failed",
161891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        "H"=>"failed"
161901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    );
161911693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($Num>0) {
161921693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return " class='".$Style{$Act}."'";
161931693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
161941693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "";
161951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
161961693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
16197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub show_number($)
16198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
161991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($_[0])
16200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
162011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        my $Num = cut_off_number($_[0], 2, 0);
162021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($Num eq "0")
162031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
162041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $P (3 .. 7)
162051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
162061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Num = cut_off_number($_[0], $P, 1);
162071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if($Num ne "0") {
162081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    last;
162091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
162101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
16211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Num eq "0") {
16213ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Num = $_[0];
16214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Num;
16216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $_[0];
16218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub cut_off_number($$$)
16221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($num, $digs_to_cut, $z) = @_;
16223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($num!~/\./)
16224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $num .= ".";
16226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut-1) {
16227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\.(.+)\Z/ and length($1)<$digs_to_cut-1)
16231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (1 .. $digs_to_cut - 1 - length($1)) {
16233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $num .= "0";
16234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($num=~/\d+\.(\d){$digs_to_cut,}/) {
16237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      $num=sprintf("%.".($digs_to_cut-1)."f", $num);
16238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $num=~s/\.[0]+\Z//g;
162401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($z) {
162411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $num=~s/(\.[1-9]+)[0]+\Z/$1/g;
162421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
16243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $num;
16244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
162468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub get_Report_ChangedConstants($$)
16247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
162488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
162491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_CONSTANTS = "";
162508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
162511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
162528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$CompatProblems_Constants{$Level}}))
162538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
162548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Header = $Constants{1}{$Constant}{"Header"};
162558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not $Header)
162568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # added
162578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $Header = $Constants{2}{$Constant}{"Header"}
162588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
162598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
162608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$CompatProblems_Constants{$Level}{$Constant}}))
162618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
162628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $CompatRules{$Level}{$Kind}) {
162638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
162648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
16265f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($TargetSeverity ne $CompatRules{$Level}{$Kind}{"Severity"}) {
162668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
162678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
162688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $ReportMap{$Header}{$Constant}{$Kind} = 1;
162698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
162701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
162718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
16272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
162741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "  <header name=\"$HeaderName\">\n";
162771693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    <constant name=\"$Constant\">\n";
162808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
162818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
162828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = $CompatRules{$Level}{$Kind}{"Change"};
162838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
162848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16285fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
162868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      <problem id=\"$Kind\">\n";
162878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <change".getXmlParams($Change, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Change</change>\n";
162888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <effect".getXmlParams($Effect, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Effect</effect>\n";
162898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "        <overcome".getXmlParams($Overcome, $CompatProblems_Constants{$Level}{$Constant}{$Kind}).">$Overcome</overcome>\n";
162908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_CONSTANTS .= "      </problem>\n";
162918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
16292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CHANGED_CONSTANTS .= "    </constant>\n";
16293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "    </header>\n";
16295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CHANGED_CONSTANTS = "<problems_with_constants severity=\"Low\">\n".$CHANGED_CONSTANTS."</problems_with_constants>\n\n";
16297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Number = 0;
163011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<span class='h_name'>$HeaderName</span><br/>\n";
163048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            foreach my $Constant (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
163068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                my $Report = "";
163078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
163088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                foreach my $Kind (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}{$Constant}}))
163098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
163108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, $CompatProblems_Constants{$Level}{$Constant}{$Kind});
163118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
163128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report .= "<tr><th>1</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>$Effect</td></tr>\n";
163138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Number += 1;
163148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
163158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Report)
163168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                {
163178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey 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";
163188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = $ContentSpanStart."<span class='extendable'>[+]</span> ".$Constant.$ContentSpanEnd."<br/>\n".$Report;
163198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $Report = insertIDs($Report);
163208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
163218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $CHANGED_CONSTANTS .= $Report;
16322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CHANGED_CONSTANTS .= "<br/>\n";
16324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
163251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CHANGED_CONSTANTS)
163261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
163278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $Title = "Problems with Constants, $TargetSeverity Severity";
163288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($TargetSeverity eq "Safe")
163298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # Safe Changes
163308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Title = "Other Changes in Constants";
163311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
163328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            $CHANGED_CONSTANTS = "<a name='".get_Anchor("Constant", $Level, $TargetSeverity)."'></a><h2>$Title ($Number)</h2><hr/>\n".$CHANGED_CONSTANTS.$TOP_REF."<br/>\n";
16333ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_CONSTANTS;
16336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Impl()
16339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
163401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $CHANGED_IMPLEMENTATION = "";
163411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
163428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Interface (sort keys(%CompatProblems_Impl))
16343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Interface}{"Header"};
16345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Interface};
163461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Changed_Number = 0;
163491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
163511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
163531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my %NameSpaceSymbols = ();
163541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1635574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
163571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
1635974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CHANGED_IMPLEMENTATION .= getTitle($HeaderName, $DyLib, $NameSpace);
163601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Interface (@SortedInterfaces)
16362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Changed_Number += 1;
16364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Interface, 1);
16365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
1636662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
16367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
163688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    $CHANGED_IMPLEMENTATION .= $ContentSpanStart.highLight_Signature_Italic_Color($Signature).$ContentSpanEnd."<br/>\n".$ContentDivStart."<span class='mangled'>[symbol: <b>$Interface</b>]</span>".$CompatProblems_Impl{$Interface}{"Diff"}."<br/><br/>".$ContentDivEnd."\n";
16369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1637074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CHANGED_IMPLEMENTATION .= "<br/>\n";
16371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1637474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($CHANGED_IMPLEMENTATION)
1637574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
1637674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $CHANGED_IMPLEMENTATION = insertIDs($CHANGED_IMPLEMENTATION);
163771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $CHANGED_IMPLEMENTATION = "<a name='Changed_Implementation'></a><h2>Problems with Implementation ($Changed_Number)</h2><hr/>\n".$CHANGED_IMPLEMENTATION.$TOP_REF."<br/>\n";
16378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16379850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
16380850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
163818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    %CompatProblems_Impl = ();
16382850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
16383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CHANGED_IMPLEMENTATION;
16384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
163861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getTitle($$$)
163871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
163881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Header, $Library, $NameSpace) = @_;
163891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Title = "";
163901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Library and $Library!~/\.\w+\Z/) {
163911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Library .= " (.$LIB_EXT)";
163921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Header and $Library)
163941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
163951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span>";
163961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= ", <span class='lib_name'>$Library</span><br/>\n";
163971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
163981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Library) {
163991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='lib_name'>$Library</span><br/>\n";
164001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
164011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Header) {
164021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title .= "<span class='h_name'>$Header</span><br/>\n";
164031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
164041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($NameSpace) {
1640574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Title .= "<span class='ns'>namespace <b>$NameSpace</b></span><br/>\n";
164061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
164071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return $Title;
164081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
164091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
16410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Added($)
16411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
164121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
164131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $ADDED_INTERFACES = "";
164141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
164151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
164171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Interface}}))
16418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Added_Symbol")
16420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $HeaderName = $CompleteSignature{2}{$Interface}{"Header"};
16422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $DyLib = $Symbol_Library{2}{$Interface};
164231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
164241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
164251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
164261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
164271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Interface} = 1;
16428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
164331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
164361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    <library name=\"$DyLib\">\n";
164391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ADDED_INTERFACES .= "      <name>$Interface</name>\n";
16441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $ADDED_INTERFACES .= "    </library>\n";
16443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ADDED_INTERFACES .= "  </header>\n";
16445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ADDED_INTERFACES = "<added_symbols>\n".$ADDED_INTERFACES."</added_symbols>\n\n";
16447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Added_Number = 0;
164511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
164531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
164551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
164561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1645774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 2)}{$Interface} = 1;
16458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
164591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
164611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
164621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 2)) cmp lc(get_Signature($b, 2))} keys(%{$NameSpaceSymbols{$NameSpace}});
16463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Interface (@SortedInterfaces)
16464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Added_Number += 1;
16466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Signature = get_Signature($Interface, 2);
16467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1646862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
164709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Interface=~/\A(_Z|\?)/)
164719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
164731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
16474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
164761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
164799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        else
164809927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
16481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
164821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16484ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
164851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $ADDED_INTERFACES .= "<span class=\"iname\">".$Interface."</span><br/>\n";
16486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16488ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
164891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $ADDED_INTERFACES .= "<br/>\n";
16490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16491ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
164931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ADDED_INTERFACES)
164941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
164951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Added'></a>";
164961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
164971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Added'></a>";
164981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
164991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ADDED_INTERFACES = $Anchor."<h2>Added Symbols ($Added_Number)</h2><hr/>\n".$ADDED_INTERFACES.$TOP_REF."<br/>\n";
16500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $ADDED_INTERFACES;
16503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Removed($)
16506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
165071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
165081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $REMOVED_INTERFACES = "";
165091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my %ReportMap = ();
16510850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16512850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
165141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Kind eq "Removed_Symbol")
16515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16516850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
16517850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
165181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
165191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
165201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
165211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
16522850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
165281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  <header name=\"$HeaderName\">\n";
165311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    <library name=\"$DyLib\">\n";
16534850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
16535850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    $REMOVED_INTERFACES .= "      <name>$Symbol</name>\n";
16536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "    </library>\n";
16538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $REMOVED_INTERFACES .= "  </header>\n";
16540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $REMOVED_INTERFACES = "<removed_symbols>\n".$REMOVED_INTERFACES."</removed_symbols>\n\n";
16542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
165451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $Removed_Number = 0;
165461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
165471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
165481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
165491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
165501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my %NameSpaceSymbols = ();
165511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Interface (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1655274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Interface, 1)}{$Interface} = 1;
16553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
165541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
165561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $REMOVED_INTERFACES .= getTitle($HeaderName, $DyLib, $NameSpace);
165571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NameSpaceSymbols{$NameSpace}});
16558850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $Removed_Number += 1;
16561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $SubReport = "";
16562850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
16563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1656462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $Signature=~s/\b\Q$NameSpace\E::\b//g;
16565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16566850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        if($Symbol=~/\A(_Z|\?)/)
165671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
16569850437949b65b213696469223d749c1f74c29601Andrey 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");
16570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16572850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16574ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
165751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        else
165761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        {
16577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
165781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
16579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
16581850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                                $REMOVED_INTERFACES .= "<span class=\"iname\">".$Symbol."</span><br/>\n";
16582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $REMOVED_INTERFACES .= "<br/>\n";
16587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
165891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($REMOVED_INTERFACES)
165901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
165911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Anchor = "<a name='Removed'></a><a name='Withdrawn'></a>";
165921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport) {
165931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Anchor = "<a name='".$Level."_Removed'></a><a name='".$Level."_Withdrawn'></a>";
165941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
165951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $REMOVED_INTERFACES = $Anchor."<h2>Removed Symbols ($Removed_Number)</h2><hr/>\n".$REMOVED_INTERFACES.$TOP_REF."<br/>\n";
16596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $REMOVED_INTERFACES;
16599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getXmlParams($$)
16602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Content, $Problem) = @_;
16604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %XMLparams = ();
16606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Content=~/\Q$Macro\E/) {
16610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $XMLparams{lc($Attr)} = $Problem->{$Attr};
16611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @PString = ();
16614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $P (sort {$b cmp $a} keys(%XMLparams)) {
166155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        push(@PString, $P."=\"".xmlSpecChars($XMLparams{$P})."\"");
16616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(@PString) {
16618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return " ".join(" ", @PString);
16619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
16622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub addMarkup($)
16626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = $_[0];
16628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # auto-markup
16629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s/\n[ ]*//; # spaces
16630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(\@\w+\s*\(\@\w+\))!<nowrap>$1</nowrap>!g; # @old_type (@old_size)
16631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(... \(\w+\))!<nowrap><b>$1</b></nowrap>!g; # ... (va_list)
166320d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!<nowrap>(.+?)</nowrap>!<span class='nowrap'>$1</span>!g;
16633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!([2-9]\))!<br/>$1!g; # 1), 2), ...
16634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/\ANOTE:/)
16635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # notes
16636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<b>$1</b>:!g;
16637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
16639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s!(NOTE):!<br/><b>$1</b>:!g;
16640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s! (out)-! <b>$1</b>-!g; # out-parameters
16642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Keywords = (
16643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "void",
16644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "const",
16645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "static",
16646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "restrict",
16647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "volatile",
16648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "register",
166490d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        "virtual"
16650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
16651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $MKeys = join("|", @Keywords);
16652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach (@Keywords) {
16653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $MKeys .= "|non-".$_;
16654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content=~s!(added\s*|to\s*|from\s*|became\s*)($MKeys)([^\w-]|\Z)!$1<b>$2</b>$3!ig; # intrinsic types, modifiers
166560d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko
166570d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    # Markdown
166580d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*\*([\w\-]+)\*\*!<b>$1</b>!ig;
166590d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    $Content=~s!\*([\w\-]+)\*!<i>$1</i>!ig;
16660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub applyMacroses($$$$)
16664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
16665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Level, $Kind, $Content, $Problem) = @_;
16666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Content or not $Problem);
16667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Problem->{"Word_Size"} = $WORD_SIZE{2};
16668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Content = addMarkup($Content);
16669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # macros
16670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Attr (sort {$b cmp $a} keys(%{$Problem}))
16671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Macro = "\@".lc($Attr);
16673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Value = $Problem->{$Attr};
16674dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(not defined $Value
16675dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        or $Value eq "") {
16676dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            next;
16677dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
166785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($Value=~/\s\(/ and $Value!~/['"]/)
16679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # functions
166801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s*\[[\w\-]+\]//g; # remove quals
166811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Value=~s/\s\w+(\)|,)/$1/g; # remove parameter names
16682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = black_name($Value);
16683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\s/) {
16685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<span class='value'>".htmlSpecChars($Value)."</span>";
16686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Value=~/\A\d+\Z/
16688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and ($Attr eq "Old_Size" or $Attr eq "New_Size"))
16689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # bits to bytes
16690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Value % $BYTE_SIZE)
16691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bits
16692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bit";
16694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bits";
16697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
16700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # bytes
16701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value /= $BYTE_SIZE;
16702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Value==1) {
16703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> byte";
16704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
16706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Value = "<b>".$Value."</b> bytes";
16707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167100d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        else
167110d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
16712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Value = "<b>".htmlSpecChars($Value)."</b>";
16713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content=~s/\Q$Macro\E/$Value/g;
16715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Content=~/(\A|[^\@\w])\@\w/)
16718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
16719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $IncompleteRules{$Level}{$Kind})
16720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # only one warning
16721ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "incomplete rule \"$Kind\" (\"$Level\")");
16722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $IncompleteRules{$Level}{$Kind} = 1;
16723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Content;
16726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16728dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub get_Report_SymbolProblems($$)
16729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
167301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
167311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $INTERFACE_PROBLEMS = "";
167321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my (%ReportMap, %SymbolChanges) = ();
167332489ef88760861175102e4508089608391beead3Andrey Ponomarenko
167341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
16735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
167361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
167371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
167381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
167391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
167401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (sort keys(%{$CompatProblems{$Level}{$Symbol}}))
16741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Symbols"
167431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            and $Kind ne "Added_Symbol" and $Kind ne "Removed_Symbol")
16744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
167451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
167461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $DyLib = $Symbol_Library{1}{$Symbol};
167471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not $DyLib and my $VSym = $SymVer{1}{$Symbol})
16748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # Symbol with Version
16749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DyLib = $Symbol_Library{1}{$VSym};
16750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1675162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $DyLib)
1675262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # const global data
1675362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $DyLib = "";
1675462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
167551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Source" and $ReportFormat eq "html")
167561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # do not show library name in HTML report
167571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $DyLib = "";
167581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
167591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$SymbolChanges{$Symbol}{$Kind}} = %{$CompatProblems{$Level}{$Symbol}{$Kind}};
167601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
167622489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
167632489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if($Severity ne $TargetSeverity) {
167641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        delete($SymbolChanges{$Symbol}{$Kind}{$Location});
16765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(not keys(%{$SymbolChanges{$Symbol}{$Kind}}))
167681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                {
167691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    delete($SymbolChanges{$Symbol}{$Kind});
167701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    next;
16771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
167721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$DyLib}{$Symbol} = 1;
16773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
167751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$SymbolChanges{$Symbol}})) {
167761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($SymbolChanges{$Symbol});
167771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
167792489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
167821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
167851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    <library name=\"$DyLib\">\n";
16788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Symbol (sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%SymbolChanges))
16789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      <symbol name=\"$Symbol\">\n";
16791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (keys(%{$SymbolChanges{$Symbol}}))
16792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
16795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
167960d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                            $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16797f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
16798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        <problem id=\"$Kind\">\n";
16799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "          <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= "        </problem>\n";
16806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "      </symbol>\n";
16809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $INTERFACE_PROBLEMS .= "    </library>\n";
16811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $INTERFACE_PROBLEMS .= "  </header>\n";
16813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $INTERFACE_PROBLEMS = "<problems_with_symbols severity=\"$TargetSeverity\">\n".$INTERFACE_PROBLEMS."</problems_with_symbols>\n\n";
16815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
16817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
16818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
168191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$ReportMap{$HeaderName}}))
16822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
168231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my (%NameSpaceSymbols, %NewSignature) = ();
168241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Symbol (keys(%{$ReportMap{$HeaderName}{$DyLib}})) {
1682574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $NameSpaceSymbols{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
16826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
168271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $NameSpace (sort keys(%NameSpaceSymbols))
16828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
168291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= getTitle($HeaderName, $DyLib, $NameSpace);
16830fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    my @SortedInterfaces = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$NameSpaceSymbols{$NameSpace}});
168311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    foreach my $Symbol (@SortedInterfaces)
16832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
168331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $Signature = get_Signature($Symbol, 1);
168341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        my $SYMBOL_REPORT = "";
16835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ProblemNum = 1;
168361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        foreach my $Kind (keys(%{$SymbolChanges{$Symbol}}))
16837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
168381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            foreach my $Location (sort keys(%{$SymbolChanges{$Symbol}{$Kind}}))
16839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
168401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                my %Problem = %{$SymbolChanges{$Symbol}{$Kind}{$Location}};
168410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                                $Problem{"Param_Pos"} = showPos($Problem{"Param_Pos"});
16842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if($Problem{"New_Signature"}) {
168431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $NewSignature{$Symbol} = $Problem{"New_Signature"};
16844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
16846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                {
16847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
168481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                    $SYMBOL_REPORT .= "<tr><th>$ProblemNum</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>".$Effect."</td></tr>\n";
16849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemNum += 1;
16850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                    $ProblemsNum += 1;
16851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                }
16852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $ProblemNum -= 1;
168551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($SYMBOL_REPORT)
16856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
168571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ";
16858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($Signature) {
168591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= highLight_Signature_Italic_Color($Signature);
16860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            else {
168621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= $Symbol;
16863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
168641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= " ($ProblemNum)".$ContentSpanEnd."<br/>\n";
168651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivStart."\n";
168661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($NewSignature{$Symbol})
168671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            { # argument list changed to
168681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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";
16869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
168701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            if($Symbol=~/\A(_Z|\?)/) {
168711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                                $INTERFACE_PROBLEMS .= "<span class='mangled'>&#160;&#160;&#160;&#160;[symbol: <b>$Symbol</b>]</span><br/>\n";
168721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            }
168731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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";
168741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                            $INTERFACE_PROBLEMS .= $ContentDivEnd;
16875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if($NameSpace) {
1687662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                                $INTERFACE_PROBLEMS=~s/\b\Q$NameSpace\E::\b//g;
16877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
16878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
16879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
168801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $INTERFACE_PROBLEMS .= "<br/>";
16881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
168842489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($INTERFACE_PROBLEMS)
16886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
168871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $INTERFACE_PROBLEMS = insertIDs($INTERFACE_PROBLEMS);
168881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Symbols, $TargetSeverity Severity";
168891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
16890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
16891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Symbols";
16892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
168930d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey 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";
16894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
16896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $INTERFACE_PROBLEMS;
16897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
16898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
16899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_TypeProblems($$)
16900ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
169011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($TargetSeverity, $Level) = @_;
169021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my $TYPE_PROBLEMS = "";
1690374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my (%ReportMap, %TypeChanges) = ();
169042489ef88760861175102e4508089608391beead3Andrey Ponomarenko
169051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Interface (sort keys(%{$CompatProblems{$Level}}))
16906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
169071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Kind (keys(%{$CompatProblems{$Level}{$Interface}}))
16908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
16910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16911f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$CompatProblems{$Level}{$Interface}{$Kind}}))
16912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
169131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $TypeName = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Type_Name"};
169141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    my $Target = $CompatProblems{$Level}{$Interface}{$Kind}{$Location}{"Target"};
16915f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
169162489ef88760861175102e4508089608391beead3Andrey Ponomarenko
169171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Severity eq "Safe"
169181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    and $TargetSeverity ne "Safe") {
16919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        next;
16920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
169211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
169222489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    if(my $MaxSeverity = $Type_MaxSeverity{$Level}{$TypeName}{$Kind}{$Target})
169232489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    {
169242489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        if($Severity_Val{$MaxSeverity}>$Severity_Val{$Severity})
169252489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        { # select a problem with the highest priority
169262489ef88760861175102e4508089608391beead3Andrey Ponomarenko                            next;
169272489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        }
16928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
169292489ef88760861175102e4508089608391beead3Andrey Ponomarenko
169302489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $TypeChanges{$TypeName}{$Kind}{$Location} = $CompatProblems{$Level}{$Interface}{$Kind}{$Location};
16931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
16934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
169352489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Kinds_Locations = ();
16937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $TypeName (keys(%TypeChanges))
16938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
169392489ef88760861175102e4508089608391beead3Andrey Ponomarenko        my %Kind_Target = ();
16940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Kind (sort keys(%{$TypeChanges{$TypeName}}))
16941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16942f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
16944f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
169451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Severity ne $TargetSeverity)
16946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # other priority
16947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Kinds_Locations{$TypeName}{$Kind}{$Location} = 1;
16951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Target = $TypeChanges{$TypeName}{$Kind}{$Location}{"Target"};
169522489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Kind_Target{$Kind}{$Target})
16953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicate target
16954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    delete($TypeChanges{$TypeName}{$Kind}{$Location});
16955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
16956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
169572489ef88760861175102e4508089608391beead3Andrey Ponomarenko                $Kind_Target{$Kind}{$Target} = 1;
1695862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $HeaderName = $TypeInfo{1}{$TName_Tid{1}{$TypeName}}{"Header"};
169591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $ReportMap{$HeaderName}{$TypeName} = 1;
16960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not keys(%{$TypeChanges{$TypeName}{$Kind}})) {
16962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                delete($TypeChanges{$TypeName}{$Kind});
16963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
16964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
169651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not keys(%{$TypeChanges{$TypeName}})) {
169661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            delete($TypeChanges{$TypeName});
169671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
16968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
169692489ef88760861175102e4508089608391beead3Andrey Ponomarenko
16970850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} keys(%{$CompatProblems{$Level}});
16971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
16972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
169731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
16974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
16975ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  <header name=\"$HeaderName\">\n";
169761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}}))
16977ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
169785c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                $TYPE_PROBLEMS .= "    <type name=\"".xmlSpecChars($TypeName)."\">\n";
16979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
16980ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
16981f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
16982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
16983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
16984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      <problem id=\"$Kind\">\n";
16985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Change = $CompatRules{$Level}{$Kind}{"Change"};
16986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <change".getXmlParams($Change, \%Problem).">$Change</change>\n";
16987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Effect = $CompatRules{$Level}{$Kind}{"Effect"};
16988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <effect".getXmlParams($Effect, \%Problem).">$Effect</effect>\n";
16989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $Overcome = $CompatRules{$Level}{$Kind}{"Overcome"};
16990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "        <overcome".getXmlParams($Overcome, \%Problem).">$Overcome</overcome>\n";
16991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $TYPE_PROBLEMS .= "      </problem>\n";
16992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
16993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16994850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                $TYPE_PROBLEMS .= getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
169951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
16996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $TYPE_PROBLEMS .= showVTables($TypeName);
16997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
16998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $TYPE_PROBLEMS .= "    </type>\n";
16999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TYPE_PROBLEMS .= "  </header>\n";
17001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $TYPE_PROBLEMS = "<problems_with_types severity=\"$TargetSeverity\">\n".$TYPE_PROBLEMS."</problems_with_types>\n\n";
17003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
17006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ProblemsNum = 0;
170071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%ReportMap))
17008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my (%NameSpace_Type) = ();
170101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $TypeName (keys(%{$ReportMap{$HeaderName}})) {
1701174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NameSpace_Type{select_Type_NS($TypeName, 1)}{$TypeName} = 1;
17012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17013ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NameSpace_Type))
17014ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
170151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= getTitle($HeaderName, "", $NameSpace);
1701674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my @SortedTypes = sort {lc(show_Type($a, 0, 1)) cmp lc(show_Type($b, 0, 1))} keys(%{$NameSpace_Type{$NameSpace}});
17017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $TypeName (@SortedTypes)
17018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $ProblemNum = 1;
17020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $TYPE_REPORT = "";
170212489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Kind (sort {$b=~/Size/ <=> $a=~/Size/} sort keys(%{$TypeChanges{$TypeName}}))
17023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17024f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        foreach my $Location (sort {cmpLocations($b, $a)} sort keys(%{$TypeChanges{$TypeName}{$Kind}}))
17025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
17026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            my %Problem = %{$TypeChanges{$TypeName}{$Kind}{$Location}};
17027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            if(my $Change = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Change"}, \%Problem))
17028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            {
17029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                my $Effect = applyMacroses($Level, $Kind, $CompatRules{$Level}{$Kind}{"Effect"}, \%Problem);
17030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $TYPE_REPORT .= "<tr><th>$ProblemNum</th><td align='left' valign='top'>".$Change."</td><td align='left' valign='top'>$Effect</td></tr>\n";
17031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemNum += 1;
17032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                                $ProblemsNum += 1;
17033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            }
17034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemNum -= 1;
17037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($TYPE_REPORT)
17038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
17039850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                        my $Affected = getAffectedSymbols($Level, $TypeName, $Kinds_Locations{$TypeName}, \@Symbols);
17040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        my $ShowVTables = "";
170411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Level eq "Binary" and grep {$_=~/Virtual|Base_Class/} keys(%{$Kinds_Locations{$TypeName}})) {
17042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $ShowVTables = showVTables($TypeName);
17043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
1704474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1704574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $TYPE_PROBLEMS .= $ContentSpanStart."<span class='extendable'>[+]</span> ".show_Type($TypeName, 1, 1)." ($ProblemNum)".$ContentSpanEnd;
170461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<br/>\n".$ContentDivStart."<table class='ptable'><tr>\n";
170471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th width='2%'></th><th width='47%'>Change</th>\n";
170481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= "<th>Effect</th></tr>".$TYPE_REPORT."</table>\n";
170491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $TYPE_PROBLEMS .= $ShowVTables.$Affected."<br/><br/>".$ContentDivEnd."\n";
17050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($NameSpace) {
1705162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                            $TYPE_PROBLEMS=~s/\b\Q$NameSpace\E::(\w|\~)/$1/g;
17052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
17054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
170551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $TYPE_PROBLEMS .= "<br/>";
17056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
170582489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TYPE_PROBLEMS)
17060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
170611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = insertIDs($TYPE_PROBLEMS);
170621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Title = "Problems with Data Types, $TargetSeverity Severity";
170631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($TargetSeverity eq "Safe")
17064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # Safe Changes
17065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Title = "Other Changes in Data Types";
17066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
170671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $TYPE_PROBLEMS = "<a name=\'".get_Anchor("Type", $Level, $TargetSeverity)."\'></a>\n<h2>$Title ($ProblemsNum)</h2><hr/>\n".$TYPE_PROBLEMS.$TOP_REF."<br/>\n";
17068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $TYPE_PROBLEMS;
17071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1707374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub show_Type($$$)
1707474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko{
1707574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my ($Name, $Html, $LibVersion) = @_;
1707674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $TType = $TypeInfo{$LibVersion}{$TName_Tid{$LibVersion}{$Name}}{"Type"};
1707774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    $TType = lc($TType);
1707874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($TType=~/struct|union|enum/) {
1707974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name=~s/\A\Q$TType\E //g;
1708074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1708174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($Html) {
1708274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = "<span class='ttype'>".$TType."</span> ".htmlSpecChars($Name);
1708374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1708474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    else {
1708574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $Name = $TType." ".$Name;
1708674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1708774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return $Name;
1708874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko}
1708974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
170901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Anchor($$$)
170911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
170921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Kind, $Level, $Severity) = @_;
170931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
170941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
170951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
170961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_".$Level."_Changes_In_".$Kind."s";
170971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
170981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
170991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_".$Level."_Problems_".$Severity;
171001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
171021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
171031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
171041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Severity eq "Safe") {
171051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return "Other_Changes_In_".$Kind."s";
171061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
171081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Kind."_Problems_".$Severity;
171091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
171101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
171111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
171121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
17113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub showVTables($)
17114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeName = $_[0];
17116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $TypeId1 = $TName_Tid{1}{$TypeName};
1711762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my %Type1 = get_Type($TypeId1, 1);
17118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Type1{"VTable"}
17119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and keys(%{$Type1{"VTable"}}))
17120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $TypeId2 = $TName_Tid{2}{$TypeName};
1712262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Type2 = get_Type($TypeId2, 2);
17123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(defined $Type2{"VTable"}
17124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and keys(%{$Type2{"VTable"}}))
17125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Indexes = map {$_=>1} (keys(%{$Type1{"VTable"}}), keys(%{$Type2{"VTable"}}));
17127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %Entries = ();
171281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            foreach my $Index (sort {int($a)<=>int($b)} (keys(%Indexes)))
17129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
171301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E1"} = simpleVEntry($Type1{"VTable"}{$Index});
171311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $Entries{$Index}{"E2"} = simpleVEntry($Type2{"VTable"}{$Index});
17132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $VTABLES = "";
17134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ReportFormat eq "xml")
17135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # XML
17136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      <vtable>\n";
171371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
171391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "        <entry offset=\"".$Index."\">\n";
171405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <old>".xmlSpecChars($Entries{$Index}{"E1"})."</old>\n";
171415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko                    $VTABLES .= "          <new>".xmlSpecChars($Entries{$Index}{"E2"})."</new>\n";
17142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $VTABLES .= "        </entry>\n";
17143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "      </vtable>\n\n";
17145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # HTML
171481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES .= "<table class='vtable'>";
17149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<tr><th width='2%'>Offset</th>";
17150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th width='45%'>Virtual Table (Old) - ".(keys(%{$Type1{"VTable"}}))." entries</th>";
17151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "<th>Virtual Table (New) - ".(keys(%{$Type2{"VTable"}}))." entries</th></tr>";
171521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                foreach my $Index (sort {int($a)<=>int($b)} (keys(%Entries)))
17153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Color1, $Color2) = ("", "");
171551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    if($Entries{$Index}{"E1"} ne $Entries{$Index}{"E2"})
17156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
171571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        if($Entries{$Index}{"E1"})
17158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        {
171591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color1 = " class='failed'";
171601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='failed'";
17161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
171631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                            $Color2 = " class='warning'";
17164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
17165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
171661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<tr><th>".$Index."</th>\n";
171671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color1>".htmlSpecChars($Entries{$Index}{"E1"})."</td>\n";
171681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $VTABLES .= "<td$Color2>".htmlSpecChars($Entries{$Index}{"E2"})."</td></tr>\n";
17169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES .= "</table><br/>\n";
17171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $VTABLES = $ContentDivStart.$VTABLES.$ContentDivEnd;
171721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $VTABLES = $ContentSpanStart_Info."[+] show v-table (old and new)".$ContentSpanEnd."<br/>\n".$VTABLES;
17173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $VTABLES;
17175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
17178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub simpleVEntry($)
17181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $VEntry = $_[0];
17183dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not defined $VEntry
17184dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    or $VEntry eq "") {
17185dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        return "";
17186dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
17187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A(.+)::(_ZThn.+)\Z/$2/; # thunks
17188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/_ZTI\w+/typeinfo/g; # typeinfo
17189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($VEntry=~/\A_ZThn.+\Z/) {
17190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $VEntry = "non-virtual thunk";
17191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    $VEntry=~s/\A\(int \(\*\)\(...\)\)\s*([a-z_])/$1/i;
17193ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # support for old GCC versions
17194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A0u\Z/(int (*)(...))0/;
17195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A4294967268u\Z/(int (*)(...))-0x000000004/;
17196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/\A&_Z\Z/& _Z/;
17197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $VEntry=~s/([^:]+)::\~([^:]+)\Z/~$1/; # destructors
17198ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VEntry;
17199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17201f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub adjustParamPos($$$)
17202f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17203f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Pos, $Symbol, $LibVersion) = @_;
17204f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol})
17205f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17206f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if(not $CompleteSignature{$LibVersion}{$Symbol}{"Static"}
17207f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        and $CompleteSignature{$LibVersion}{$Symbol}{"Class"})
17208f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17209f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return $Pos-1;
17210f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17211f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17212f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        return $Pos;
17213f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17214f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17215f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17216f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17217f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17218f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamPos($$$)
17219f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17220f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Name, $Symbol, $LibVersion) = @_;
17221f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17222f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $CompleteSignature{$LibVersion}{$Symbol}
17223f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and defined $CompleteSignature{$LibVersion}{$Symbol}{"Param"})
17224f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17225f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17226f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach (keys(%{$Info->{"Param"}}))
17227f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17228f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info->{"Param"}{$_}{"name"} eq $Name)
17229f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17230f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                return $_;
17231f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17232f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17233f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17234f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17235f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return undef;
17236f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17237f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17238f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getParamName($)
17239f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17240f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Loc = $_[0];
17241f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Loc=~s/\->.*//g;
17242f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $Loc;
17243f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17245850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub getAffectedSymbols($$$$)
17246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17247850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($Level, $Target_TypeName, $Kinds_Locations, $Syms) = @_;
17248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LIMIT = 1000;
17249f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17250f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if(defined $AffectLimit)
17251f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17252f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        $LIMIT = $AffectLimit;
17253f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17254f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    else
17255f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
172562489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if($#{$Syms}>=1999)
17257f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        { # reduce size of the report
172582489ef88760861175102e4508089608391beead3Andrey Ponomarenko            $AffectLimit = 10;
172592489ef88760861175102e4508089608391beead3Andrey Ponomarenko
172602489ef88760861175102e4508089608391beead3Andrey Ponomarenko            printMsg("WARNING", "reducing limit of affected symbols shown in the report to $AffectLimit");
172612489ef88760861175102e4508089608391beead3Andrey Ponomarenko            $LIMIT = $AffectLimit;
17262f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17263850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
17264850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my %SProblems = ();
172652489ef88760861175102e4508089608391beead3Andrey Ponomarenko    LOOP: foreach my $Symbol (@{$Syms})
17266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
172672489ef88760861175102e4508089608391beead3Andrey Ponomarenko        if(index($Symbol, "_Z")==0
172682489ef88760861175102e4508089608391beead3Andrey Ponomarenko        and $Symbol=~/(C2|D2|D0)[EI]/)
17269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # duplicated problems for C2 constructors, D2 and D0 destructors
17270ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
172722489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17273dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my ($MinPath_Length, $ProblemLocation_Last) = (-1, "");
17274dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $Severity_Max = 0;
172752489ef88760861175102e4508089608391beead3Andrey Ponomarenko
172762489ef88760861175102e4508089608391beead3Andrey Ponomarenko        foreach my $Kind (keys(%{$Kinds_Locations}))
17277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
172782489ef88760861175102e4508089608391beead3Andrey Ponomarenko            if(not defined $CompatProblems{$Level}{$Symbol}
172792489ef88760861175102e4508089608391beead3Andrey Ponomarenko            or not defined $CompatProblems{$Level}{$Symbol}{$Kind}) {
172802489ef88760861175102e4508089608391beead3Andrey Ponomarenko                next;
172812489ef88760861175102e4508089608391beead3Andrey Ponomarenko            }
172822489ef88760861175102e4508089608391beead3Andrey Ponomarenko
172832489ef88760861175102e4508089608391beead3Andrey Ponomarenko            foreach my $Location (keys(%{$Kinds_Locations->{$Kind}}))
17284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
172852489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if(keys(%SProblems)>$LIMIT) {
172862489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    last LOOP;
172872489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
172882489ef88760861175102e4508089608391beead3Andrey Ponomarenko
172892489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if(not defined $CompatProblems{$Level}{$Symbol}{$Kind}{$Location}) {
17290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
172922489ef88760861175102e4508089608391beead3Andrey Ponomarenko
172932489ef88760861175102e4508089608391beead3Andrey Ponomarenko                my ($SN, $SS, $SV) = separate_symbol($Symbol);
172942489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Level eq "Source")
172952489ef88760861175102e4508089608391beead3Andrey Ponomarenko                { # remove symbol version
172962489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Symbol=$SN;
172972489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
172982489ef88760861175102e4508089608391beead3Andrey Ponomarenko
172991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($SV and defined $CompatProblems{$Level}{$SN}
173001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and defined $CompatProblems{$Level}{$SN}{$Kind}{$Location})
17301ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # duplicated problems for versioned symbols
17302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
17303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
173042489ef88760861175102e4508089608391beead3Andrey Ponomarenko
173051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                my $Type_Name = $CompatProblems{$Level}{$Symbol}{$Kind}{$Location}{"Type_Name"};
173062489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Type_Name ne $Target_TypeName) {
173072489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    next;
173082489ef88760861175102e4508089608391beead3Andrey Ponomarenko                }
17309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17310f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PName = getParamName($Location);
17311f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PPos = adjustParamPos(getParamPos($PName, $Symbol, 1), $Symbol, 1);
17312f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17313f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Severity = $CompatRules{$Level}{$Kind}{"Severity"};
17314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Path_Length = 0;
17315ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $ProblemLocation = $Location;
17316ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Type_Name) {
17317ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemLocation=~s/->\Q$Type_Name\E\Z//g;
17318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17319dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                while($ProblemLocation=~/\-\>/g) {
17320dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $Path_Length += 1;
17321dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                }
17322dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                if($MinPath_Length==-1 or ($Path_Length<=$MinPath_Length and $Severity_Val{$Severity}>$Severity_Max)
17323f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                or (cmpLocations($ProblemLocation, $ProblemLocation_Last) and $Severity_Val{$Severity}==$Severity_Max))
17324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
17325ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MinPath_Length = $Path_Length;
17326dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    $Severity_Max = $Severity_Val{$Severity};
17327ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ProblemLocation_Last = $ProblemLocation;
17328850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    %{$SProblems{$Symbol}} = (
17329f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Descr"=>getAffectDesc($Level, $Symbol, $Kind, $Location),
17330dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        "Severity_Max"=>$Severity_Max,
173312489ef88760861175102e4508089608391beead3Andrey Ponomarenko                        "Signature"=>get_Signature($Symbol, 1),
17332f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Position"=>$PPos,
17333f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                        "Param_Name"=>$PName,
17334ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        "Location"=>$Location
17335ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    );
17336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17340850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my @Symbols = keys(%SProblems);
173411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    @Symbols = sort {lc($tr_name{$a}?$tr_name{$a}:$a) cmp lc($tr_name{$b}?$tr_name{$b}:$b)} @Symbols;
17342850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    @Symbols = sort {$SProblems{$b}{"Severity_Max"}<=>$SProblems{$a}{"Severity_Max"}} @Symbols;
17343850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if($#Symbols+1>$LIMIT)
17344850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # remove last element
17345850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        pop(@Symbols);
17346850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    }
17347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Affected = "";
17348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
17350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      <affected>\n";
173511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Symbol (@Symbols)
17352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17353850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Param_Name = $SProblems{$Symbol}{"Param_Name"};
17354850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Description = $SProblems{$Symbol}{"Descr"};
17355850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Location = $SProblems{$Symbol}{"Location"};
17356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Target = "";
17357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Param_Name) {
17358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Target = " affected=\"param\" param_name=\"$Param_Name\"";
17359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/\Aretval(\-|\Z)/i) {
17361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Target = " affected=\"retval\"";
17362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/\Athis(\-|\Z)/i) {
17364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Target = " affected=\"this\"";
17365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
173661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Affected .= "        <symbol$Target name=\"$Symbol\">\n";
173675c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Affected .= "          <comment>".xmlSpecChars($Description)."</comment>\n";
17368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected .= "        </symbol>\n";
17369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Affected .= "      </affected>\n";
17371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
173741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        foreach my $Symbol (@Symbols)
17375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17376850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Description = $SProblems{$Symbol}{"Descr"};
17377850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Signature = $SProblems{$Symbol}{"Signature"};
17378850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Pos = $SProblems{$Symbol}{"Position"};
17379a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            $Affected .= "<span class='iname_a'>".highLight_Signature_PPos_Italic($Signature, $Pos, 1, 0, 0)."</span><br/><div class='affect'>".htmlSpecChars($Description)."</div>\n";
17380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17381850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(keys(%SProblems)>$LIMIT) {
173822489ef88760861175102e4508089608391beead3Andrey Ponomarenko            $Affected .= " ...<br/>"; # and others ...
17383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17384850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        $Affected = "<div class='affected'>".$Affected."</div>";
17385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Affected)
17386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Affected = $ContentDivStart.$Affected.$ContentDivEnd;
17388850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            $Affected = $ContentSpanStart_Affected."[+] affected symbols (".(keys(%SProblems)>$LIMIT?">".$LIMIT:keys(%SProblems)).")".$ContentSpanEnd.$Affected;
17389ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
173912489ef88760861175102e4508089608391beead3Andrey Ponomarenko
17392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Affected;
17393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17395f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub cmpLocations($$)
17396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
1739762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($L1, $L2) = @_;
17398f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    if($L2=~/\A(retval|this)\b/
17399f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    and $L1!~/\A(retval|this)\b/)
17400f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17401f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($L1!~/\-\>/) {
17402f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17403f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17404f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        elsif($L2=~/\-\>/) {
17405f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            return 1;
17406f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
17409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17411f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getAffectDesc($$$$)
17412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
174131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Symbol, $Kind, $Location) = @_;
17414f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
174151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my %Problem = %{$CompatProblems{$Level}{$Symbol}{$Kind}{$Location}};
17416f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17417f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my $Location_I = $Location;
17418f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Location=~s/\A(.*)\-\>(.+?)\Z/$1/; # without the latest affected field
17419f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Sentence = ();
17421f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Kind eq "Overridden_Virtual_Method"
17423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $Kind eq "Overridden_Virtual_Method_B") {
17424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        push(@Sentence, "The method '".$Problem{"New_Value"}."' will be called instead of this method.");
17425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($CompatRules{$Level}{$Kind}{"Kind"} eq "Types")
17427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17428f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %SymInfo = %{$CompleteSignature{1}{$Symbol}};
17429f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Location eq "this" or $Kind=~/(\A|_)Virtual(_|\Z)/)
17431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17432f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $METHOD_TYPE = $SymInfo{"Constructor"}?"constructor":"method";
17433f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $ClassName = $TypeInfo{1}{$SymInfo{"Class"}}{"Name"};
17434f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ClassName eq $Problem{"Type_Name"}) {
17436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from \'".$Problem{"Type_Name"}."\' class.");
17437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
17439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "This $METHOD_TYPE is from derived class \'".$ClassName."\'.");
17440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
17443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17444f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            my $TypeID = undef;
17445f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location=~/retval/)
17447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # return value
17448f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in return value");
17450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Return value");
17453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17454f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17455f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Return"};
17456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Location=~/this/)
17458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # "this" pointer
17459f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in the object of this method");
17461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    push(@Sentence, "\'this\' pointer");
17464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17465f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17466f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Class"};
17467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
17469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # parameters
17470f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17471f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PName = getParamName($Location);
17472f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $PPos = getParamPos($PName, $Symbol, 1);
17473f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17474f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(index($Location, "->")!=-1) {
17475f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "Field \'".$Location."\' in ".showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
17478f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, showPos(adjustParamPos($PPos, $Symbol, 1))." parameter");
17479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17480f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($PName) {
17481f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "\'".$PName."\'");
17482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17483f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17484f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeID = $SymInfo{"Param"}{$PPos}{"type"};
17485f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17486f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17487f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Location!~/this/)
17488f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17489f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(my %PureType = get_PureType($TypeID, $TypeInfo{1}))
17490dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                {
17491f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    if($PureType{"Type"} eq "Pointer") {
17492dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(pointer)");
17493dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17494f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    elsif($PureType{"Type"} eq "Ref") {
17495dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                        push(@Sentence, "(reference)");
17496dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                    }
17497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
17498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17499f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Location eq "this") {
17501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17503f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            else
17504f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17505f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $Location_T = $Location;
17506f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $Location_T=~s/\A\w+(\->|\Z)//; # location in type
17507f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17508f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                my $TypeID_Problem = $TypeID;
17509f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($Location_T) {
17510f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $TypeID_Problem = getFieldType($Location_T, $TypeID, 1);
17511f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17512f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17513f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($TypeInfo{1}{$TypeID_Problem}{"Name"} eq $Problem{"Type_Name"}) {
17514f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has type \'".$Problem{"Type_Name"}."\'.");
17515f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17516f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                else {
17517f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    push(@Sentence, "has base type \'".$Problem{"Type_Name"}."\'.");
17518f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
17519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1752262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($ExtendedSymbols{$Symbol}) {
175238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        push(@Sentence, " This is a symbol from an external library that may use the \'$TargetLibraryName\' library and change the ABI after recompiling.");
17524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return join(" ", @Sentence);
17526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17528f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenkosub getFieldType($$$)
17529f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko{
17530f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my ($Location, $TypeId, $LibVersion) = @_;
17531f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17532f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    my @Fields = split("->", $Location);
17533f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17534f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $Name (@Fields)
17535f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    {
17536f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my %Info = get_BaseType($TypeId, $LibVersion);
17537f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17538f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        foreach my $Pos (keys(%{$Info{"Memb"}}))
17539f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        {
17540f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            if($Info{"Memb"}{$Pos}{"name"} eq $Name)
17541f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
17542f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                $TypeId = $Info{"Memb"}{$Pos}{"type"};
17543f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                last;
17544f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            }
17545f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
17546f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    }
17547f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17548f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    return $TypeId;
17549f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko}
17550f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
17551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_XmlSign($$)
17552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
17554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Info = $CompleteSignature{$LibVersion}{$Symbol};
17555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "";
17556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Pos (sort {int($a)<=>int($b)} keys(%{$Info->{"Param"}}))
17557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $Name = $Info->{"Param"}{$Pos}{"name"};
1755962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $Type = $Info->{"Param"}{$Pos}{"type"};
1756062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $TypeName = $TypeInfo{$LibVersion}{$Type}{"Name"};
17561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Typedef (keys(%ChangedTypedef))
17562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
175638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(my $Base = $Typedef_BaseName{$LibVersion}{$Typedef}) {
175648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $TypeName=~s/\b\Q$Typedef\E\b/$Base/g;
175658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
17566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <param pos=\"$Pos\">\n";
17568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "      <name>".$Name."</name>\n";
175695c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($TypeName)."</type>\n";
17570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </param>\n";
17571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17572ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Return = $Info->{"Return"})
17573ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1757462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $RTName = $TypeInfo{$LibVersion}{$Return}{"Name"};
17575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    <retval>\n";
175765c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $Report .= "      <type>".xmlSpecChars($RTName)."</type>\n";
17577ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "    </retval>\n";
17578ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17579ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17580ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17581ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
175821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub get_Report_SymbolsInfo($)
17583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
175841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Report = "<symbols_info>\n";
175861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompatProblems{$Level}}))
17587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
175881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my ($SN, $SS, $SV) = separate_symbol($Symbol);
175891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SV and defined $CompatProblems{$Level}{$SN}) {
17590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
17591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  <symbol name=\"$Symbol\">\n";
17593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($S1, $P1, $S2, $P2) = ();
175941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $AddedInt{$Level}{$Symbol})
17595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{1}{$Symbol}
17597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{1}{$Symbol}{"Header"})
17598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17599ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P1 = get_XmlSign($Symbol, 1);
17600ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = get_Signature($Symbol, 1);
17601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S1 = $tr_name{$Symbol};
17604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17605ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
176061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not $RemovedInt{$Level}{$Symbol})
17607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(defined $CompleteSignature{2}{$Symbol}
17609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            and defined $CompleteSignature{2}{$Symbol}{"Header"})
17610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17611ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $P2 = get_XmlSign($Symbol, 2);
17612ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = get_Signature($Symbol, 2);
17613ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($Symbol=~/\A(_Z|\?)/) {
17615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $S2 = $tr_name{$Symbol};
17616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17617ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S1)
17619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <old signature=\"".xmlSpecChars($S1)."\">\n";
17621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P1;
17622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </old>\n";
17623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($S2 and $S2 ne $S1)
17625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
176265c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $Report .= "    <new signature=\"".xmlSpecChars($S2)."\">\n";
17627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= $P2;
17628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Report .= "    </new>\n";
17629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Report .= "  </symbol>\n";
17631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Report .= "</symbols_info>\n";
17633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
176361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub writeReport($$)
17637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
176381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Level, $Report) = @_;
176391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($ReportFormat eq "xml") {
176401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Report = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n".$Report;
176411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
176431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --stdout option
176441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        print STDOUT $Report;
176451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
176471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
176481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $RPath = getReportPath($Level);
17649850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        mkpath(get_dirname($RPath));
17650850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
17651850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(REPORT, ">", $RPath) || die ("can't open file \'$RPath\': $!\n");
17652850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        print REPORT $Report;
17653850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(REPORT);
17654850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1765562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Browse or $OpenReport)
1765662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # open in browser
1765762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            openReport($RPath);
176581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport or $DoubleReport)
176591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
176601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if($Level eq "Binary")
176611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # wait to open a browser
176621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    sleep(1);
176631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
176641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
176651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
176661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
176671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
176681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
1766962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub openReport($)
1767062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1767162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Path = $_[0];
1767262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my $Cmd = "";
1767362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Browse)
1767462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # user-defined browser
17675a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        $Cmd = $Browse." \"$Path\"";
1767662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1767762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not $Cmd)
1767862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # default browser
1767962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($OSgroup eq "macos") {
17680f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Cmd = "open \"$Path\"";
1768162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1768262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif($OSgroup eq "windows") {
17683f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $Cmd = "start ".path_format($Path, $OSgroup);
1768462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1768562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        else
1768662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # linux, freebsd, solaris
1768762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @Browsers = (
1768862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "x-www-browser",
1768962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "sensible-browser",
1769062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "firefox",
1769162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "opera",
1769262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "xdg-open",
1769362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "lynx",
1769462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                "links"
1769562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            );
1769662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Br (@Browsers)
1769762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1769862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Br = get_CmdPath($Br))
1769962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
17700a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Cmd = $Br." \"$Path\"";
1770162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    last;
1770262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1770362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1770462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1770562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1770662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($Cmd)
1770762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
1770862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug) {
1770962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running $Cmd");
1771062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
17711f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($OSgroup ne "windows"
17712f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        and $OSgroup ne "macos")
17713f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        {
17714f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($Cmd!~/lynx|links/) {
177158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                $Cmd .= "  >\"/dev/null\" 2>&1 &";
17716f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
1771762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
1771862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        system($Cmd);
1771962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1772062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else {
1772162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        printMsg("ERROR", "cannot open report in browser");
1772262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
1772362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1772462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
177251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReport($)
177261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
177271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
17728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "xml")
17729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # XML
177301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
177311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<reports>\n";
177331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Binary");
177341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= getReport("Source");
177351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</reports>\n";
177361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
177381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
177391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<report kind=\"".lc($Level)."\" version=\"$XML_REPORT_VERSION\">\n\n";
177411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
177421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= $Summary."\n";
177431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
177441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
177451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_SymbolsInfo($Level);
177461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</report>\n";
177471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
17751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # HTML
177521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $CssStyles = readModule("Styles", "Report.css");
177531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        my $JScripts = readModule("Scripts", "Sections.js");
177541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Level eq "Join")
177551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $CssStyles .= "\n".readModule("Styles", "Tabs.css");
177571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JScripts .= "\n".readModule("Scripts", "Tabs.js");
17758b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Title = $TargetLibraryFName.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." compatibility report";
17759b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Keywords = $TargetLibraryFName.", compatibility, API, report";
177601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Description = "Compatibility report for the $TargetLibraryFName $TargetComponent between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
177611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($BSummary, $BMetaData) = get_Summary("Binary");
177621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($SSummary, $SMetaData) = get_Summary("Source");
177631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
177641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Header("Join")."
177651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            <br/><div class='tabset'>
177661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='BinaryID' href='#BinaryTab' class='tab active'>Binary<br/>Compatibility</a>
177671693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            <a id='SourceID' href='#SourceTab' style='margin-left:3px' class='tab disabled'>Source<br/>Compatibility</a>
177681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            </div>";
177691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
177701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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>";
177719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Report .= getReportFooter($TargetLibraryFName, not $JoinReport);
177721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "\n<div style='height:999px;'></div>\n</body></html>";
177731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
177751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
177761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        {
177771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my ($Summary, $MetaData) = get_Summary($Level);
17778b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Title = $TargetLibraryFName.": ".$Descriptor{1}{"Version"}." to ".$Descriptor{2}{"Version"}." ".lc($Level)." compatibility report";
17779b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Keywords = $TargetLibraryFName.", ".lc($Level)." compatibility, API, report";
17780b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $Description = "$Level compatibility report for the ".$TargetLibraryFName." ".$TargetComponent." between ".$Descriptor{1}{"Version"}." and ".$Descriptor{2}{"Version"}." versions";
177811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($Level eq "Binary")
177821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
177831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                if(getArch(1) eq getArch(2)
177841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                and getArch(1) ne "unknown") {
177851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Description .= " on ".showArch(getArch(1));
177861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
177871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            }
177881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            my $Report = "<!-\- $MetaData -\->\n".composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."\n<body>\n<div><a name='Top'></a>\n";
177891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Header($Level)."\n".$Summary."\n";
177901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Added($Level).get_Report_Removed($Level);
177911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_Report_Problems("High", $Level).get_Report_Problems("Medium", $Level).get_Report_Problems("Low", $Level).get_Report_Problems("Safe", $Level);
177921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= get_SourceInfo();
177931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "</div>\n<br/><br/><br/><hr/>\n";
177949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Report .= getReportFooter($TargetLibraryFName, not $JoinReport);
177951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $Report .= "\n<div style='height:999px;'></div>\n</body></html>";
177961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Report;
177971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
17798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
177991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
178001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
178011693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getLegend()
178021693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
178031693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "<br/>
178041693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<table class='summary'>
178051693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
178061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='new'>added</td>
178071693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='passed'>compatible</td>
178081693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr>
178091693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko<tr>
178101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='warning'>warning</td>
178111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    <td class='failed'>incompatible</td>
178121693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko</tr></table>\n";
178131693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
178141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
178151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub createReport()
178161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
178171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport)
178180d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko    { # --stdout
178191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Join", getReport("Join"));
17820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
178211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($DoubleReport)
178221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
178231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
178241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
178251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
178261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
178271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
178281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Binary", getReport("Binary"));
178291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
178301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
178311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
178321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeReport("Source", getReport("Source"));
17833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
178369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getReportFooter($$)
17837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
178389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibName, $Wide) = @_;
178399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $FooterStyle = $Wide?"width:99%":"width:97%;padding-top:3px";
178401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Footer = "<div style='$FooterStyle;font-size:11px;' align='right'><i>Generated on ".(localtime time); # report date
17841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Footer .= " for <span style='font-weight:bold'>$LibName</span>"; # tested library/system name
178421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Footer .= " by <a href='".$HomePage{"Wiki"}."'>ABI Compliance Checker</a>"; # tool name
178431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ToolSummary = "<br/>A tool for checking backward compatibility of a C/C++ library API&#160;&#160;";
17844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Footer .= " $TOOL_VERSION &#160;$ToolSummary</i></div>"; # tool version
17845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Footer;
17846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_Report_Problems($$)
17849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
178502489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my ($Severity, $Level) = @_;
178512489ef88760861175102e4508089608391beead3Andrey Ponomarenko    my $Report = get_Report_TypeProblems($Severity, $Level);
178522489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if(my $SProblems = get_Report_SymbolProblems($Severity, $Level)) {
178531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        $Report .= $SProblems;
17854dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
178552489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($Severity eq "Low")
17856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
178578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Report .= get_Report_ChangedConstants("Low", $Level);
1785882bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        if($ReportFormat eq "html")
1785982bc2570d1240318635ef2037ac5c1a8669806d0Andrey Ponomarenko        {
17860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckImpl and $Level eq "Binary") {
17861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Report .= get_Report_Impl();
17862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
178652489ef88760861175102e4508089608391beead3Andrey Ponomarenko    if($Severity eq "Safe")
178668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
178678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Report .= get_Report_ChangedConstants("Safe", $Level);
178688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
17869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat eq "html")
17870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Report)
17872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # add anchor
178731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            if($JoinReport)
178741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
178752489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
178761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_".$Level."_Changes\'></a>".$Report;
178771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
178781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
178792489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_".$Level."_Problems\'></a>".$Report;
178801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
178821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            else
178831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            {
178842489ef88760861175102e4508089608391beead3Andrey Ponomarenko                if($Severity eq "Safe") {
178851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                    $Report = "<a name=\'Other_Changes\'></a>".$Report;
178861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
178871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                else {
178882489ef88760861175102e4508089608391beead3Andrey Ponomarenko                    $Report = "<a name=\'".$Severity."_Risk_Problems\'></a>".$Report;
178891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                }
17890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
17891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Report;
17894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
178961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub composeHTML_Head($$$$$)
17897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
178981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Title, $Keywords, $Description, $Styles, $Scripts) = @_;
178991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">
179001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">
179011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <head>
17902ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />
17903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"keywords\" content=\"$Keywords\" />
17904ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <meta name=\"description\" content=\"$Description\" />
179051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <title>
179061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $Title
179071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </title>
179081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <style type=\"text/css\">
179091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Styles
179101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </style>
179111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <script type=\"text/javascript\" language=\"JavaScript\">
179121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    <!--
179131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $Scripts
179141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    -->
179151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </script>
179161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    </head>";
17917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub insertIDs($)
17920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Text = $_[0];
17922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while($Text=~/CONTENT_ID/)
17923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
17924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(int($Content_Counter)%2) {
17925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $ContentID -= 1;
17926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
17927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Text=~s/CONTENT_ID/c_$ContentID/;
17928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ContentID += 1;
17929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Content_Counter += 1;
17930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
17931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Text;
17932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
17933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
17934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkPreprocessedUnit($)
17935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
17936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
17937a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my ($CurHeader, $CurHeaderName) = ("", "");
1793874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $CurClass = ""; # extra info
179391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    open(PREPROC, $Path) || die ("can't open file \'$Path\': $!\n");
1794074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17941a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    while(my $Line = <PREPROC>)
179421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting public and private constants
17943a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(substr($Line, 0, 1) eq "#")
17944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
17945a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            chomp($Line);
17946a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if($Line=~/\A\#\s+\d+\s+\"(.+)\"/)
17947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
17948a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeader = path_format($1, $OSgroup);
17949a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $CurHeaderName = get_filename($CurHeader);
1795074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $CurClass = "";
1795174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1795274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(index($CurHeader, $TMP_DIR)==0) {
1795374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    next;
1795474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1795574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
17956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(substr($CurHeaderName, 0, 1) eq "<")
17957fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # <built-in>, <command-line>, etc.
17958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeaderName = "";
17959fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $CurHeader = "";
17960fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
17961fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1796274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($ExtraInfo)
1796374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
17964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
1796574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $PreprocessedHeaders{$Version}{$CurHeader} = 1;
1796674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
1796774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
17968a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
1796974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not $ExtraDump)
179704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            {
17971fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($CurHeaderName)
17972fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
17973fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not $Include_Neighbors{$Version}{$CurHeaderName}
17974fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not $Registered_Headers{$Version}{$CurHeader})
17975fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # not a target
17976fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17977fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17978fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(not is_target_header($CurHeaderName, 1)
17979fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    and not is_target_header($CurHeaderName, 2))
17980fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # user-defined header
17981fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
17982fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
179834b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                }
17984a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
179854b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko
179869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Line=~/\A\#\s*define\s+(\w+)\s+(.+)\s*\Z/)
17987a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
17988a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                my ($Name, $Value) = ($1, $2);
17989a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                if(not $Constants{$Version}{$Name}{"Access"})
17990a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                {
17991a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Access"} = "public";
17992a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    $Constants{$Version}{$Name}{"Value"} = $Value;
17993fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($CurHeaderName) {
17994fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Constants{$Version}{$Name}{"Header"} = $CurHeaderName;
17995fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
17996a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                }
17997a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            }
17998a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            elsif($Line=~/\A\#[ \t]*undef[ \t]+([_A-Z]+)[ \t]*/) {
17999a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                $Constants{$Version}{$1}{"Access"} = "private";
18000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1800274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        else
1800374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1800474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $ExtraDump)
1800574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1800674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/(\w+)\s*\(/)
1800774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                { # functions
1800874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1800974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1801074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #elsif($Line=~/(\w+)\s*;/)
1801174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #{ # data
1801274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #    $SymbolHeader{$Version}{$CurClass}{$1} = $CurHeader;
1801374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                #}
1801474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                elsif($Line=~/(\A|\s)class\s+(\w+)/) {
1801574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $CurClass = $2;
1801674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
1801774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
1801874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
18019ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18020ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    close(PREPROC);
18021ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{$Version}}))
18022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1802374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if($Constants{$Version}{$Constant}{"Access"} eq "private")
1802474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
1802574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
1802674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            next;
1802774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
18028177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        if(not $ExtraDump and ($Constant=~/_h\Z/i
18029177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        or isBuiltIn($Constants{$Version}{$Constant}{"Header"})))
1803074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # skip
1803174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            delete($Constants{$Version}{$Constant});
18032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            delete($Constants{$Version}{$Constant}{"Access"});
18035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18037a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug)
18038a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    {
18039a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        mkpath($DEBUG_PATH{$Version});
18040a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        copy($Path, $DEBUG_PATH{$Version}."/preprocessor.txt");
18041a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
18042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
180441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub uncoverConstant($$)
180451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
180461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($LibVersion, $Constant) = @_;
180471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return "" if(not $LibVersion or not $Constant);
180481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return $Constant if(isCyclical(\@RecurConstant, $Constant));
180491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Cache{"uncoverConstant"}{$LibVersion}{$Constant}) {
180501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return $Cache{"uncoverConstant"}{$LibVersion}{$Constant};
180511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18052fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $Constants{$LibVersion}{$Constant})
180541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
18055fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value = $Constants{$LibVersion}{$Constant}{"Value"};
18056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(defined $Constants{$LibVersion}{$Value})
180571693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
180581693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            push(@RecurConstant, $Constant);
180591693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            my $Uncovered = uncoverConstant($LibVersion, $Value);
180601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Uncovered ne "") {
180611693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $Value = $Uncovered;
180621693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
180631693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            pop(@RecurConstant);
180641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18065fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
180661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        # FIXME: uncover $Value using all the enum constants
18067fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        # USE CASE: change of define NC_LONG from NC_INT (enum value) to NC_INT (define)
180681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = $Value);
180691693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
180701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return ($Cache{"uncoverConstant"}{$LibVersion}{$Constant} = "");
180711693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
180721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
18073fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub simpleConstant($$)
18074fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
18075fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my ($LibVersion, $Value) = @_;
18076fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\W/)
18077fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
18078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        my $Value_Copy = $Value;
18079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        while($Value_Copy=~s/([a-z_]\w+)/\@/i)
18080fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18081fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Word = $1;
18082fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if($Value!~/$Word\s*\(/)
18083fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18084fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my $Val = uncoverConstant($LibVersion, $Word);
18085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Val ne "")
18086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18087fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Value=~s/\b$Word\b/$Val/g;
18088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18089fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18090fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18091fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18092fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
18093fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
18094fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18095fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub computeValue($)
18096fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko{
18097fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my $Value = $_[0];
18098fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18099fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A\((-?[\d]+)\)\Z/) {
18100fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return $1;
18101fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18102fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18103fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($Value=~/\A[\d\-\+()]+\Z/) {
18104fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        return eval($Value);
18105fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18106fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18107fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    return $Value;
18108fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko}
18109fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
181109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %IgnoreConstant = map {$_=>1} (
181119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSION",
181129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERSIONCODE",
181139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERNUM",
181149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VERS_INFO",
181159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCHLEVEL",
181169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLPREFIX",
181179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VBUILD",
181189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VPATCH",
181199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "VMINOR",
181209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_STRING",
181219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BUILD_TIME",
181229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_STRING",
181239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PRODUCTION",
181249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIGURE_COMMAND",
181259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INSTALLDIR",
181269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINDIR",
181279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CONFIG_FILE_PATH",
181289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DATADIR",
181299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "EXTENSION_DIR",
181309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INCLUDE_PATH",
181319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LIBDIR",
181329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "LOCALSTATEDIR",
181339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SBINDIR",
181349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SYSCONFDIR",
181359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "RELEASE",
181369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SOURCE_ID",
181379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SUBMINOR",
181389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINOR",
181399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINNOR",
181409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MINORVERSION",
181419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJOR",
181429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MAJORVERSION",
181439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICRO",
181449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "MICROVERSION",
181459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BINARY_AGE",
181469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "INTERFACE_AGE",
181479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "CORE_ABI",
181489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PATCH",
181499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COPYRIGHT",
181509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "TIMESTAMP",
181519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "REVISION",
181529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGE_TAG",
181539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PACKAGEDATE",
181549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NUMVERSION",
181559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Release",
181569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "Version"
18157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko);
18158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
181598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub constantFilter($$$)
181608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
181618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Name, $Value, $Level) = @_;
181628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
181638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Level eq "Binary")
181648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
18165fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Name=~/_t\Z/)
18166fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # __malloc_ptr_t
18167fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 1;
18168fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
181698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        foreach (keys(%IgnoreConstant))
181708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
181718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($Name=~/(\A|_)$_(_|\Z)/)
181728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # version
181738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
181748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(/\A[A-Z].*[a-z]\Z/)
181768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            {
181778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if($Name=~/(\A|[a-z])$_([A-Z]|\Z)/)
181788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                { # version
181798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    return 1;
181808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                }
181818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
181828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
181838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Name=~/(\A|_)(lib|open|)$TargetLibraryShortName(_|)(VERSION|VER|DATE|API|PREFIX)(_|\Z)/i)
181848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # version
181858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
181878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Value=~/\A('|"|)[\/\\]\w+([\/\\]|:|('|"|)\Z)/ or $Value=~/[\/\\]\w+[\/\\]\w+/)
181888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # /lib64:/usr/lib64:/lib:/usr/lib:/usr/X11R6/lib/Xaw3d ...
181898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
181908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18191fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A["'].*['"]/i)
18193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # string
18194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            return 0;
18195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[({]*\s*[a-z_]+\w*(\s+|[\|,])/i)
18198fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # static int gcry_pth_init
18199fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # extern ABC
182008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # (RE_BACKSLASH_ESCAPE_IN_LISTS | RE...
18201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # { H5FD_MEM_SUPER, H5FD_MEM_SUPER, ...
182028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\w+\s*\(/i)
182058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # foo(p)
182068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
18208fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Value=~/\A[a-z_]+\w*\Z/i)
182098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # asn1_node_st
18210fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko          # __SMTH_P
182118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1;
182128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
182148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
182168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
182178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub mergeConstants($)
18219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
182201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
18221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Constant (keys(%{$Constants{1}}))
18222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SkipConstants{1}{$Constant})
18224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skipped by the user
18225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
182278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18228fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(my $Header = $Constants{1}{$Constant}{"Header"})
18229fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
18230fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(not is_target_header($Header, 1)
18231fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            and not is_target_header($Header, 2))
18232fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # user-defined header
18233fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18234fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18235fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18236fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        else {
18237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
18238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
182398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value = uncoverConstant(1, $Constant);
182418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(constantFilter($Constant, $Old_Value, $Level))
182438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # separate binary and source problems
182448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{2}{$Constant}{"Value"})
182488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # removed
182498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Removed_Constant"}} = (
182508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
182518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Old_Value"=>$Old_Value  );
182528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($Constants{2}{$Constant}{"Value"} eq "")
182568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # empty value
182578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko          # TODO: implement a rule
182588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            next;
182598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
182608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value = uncoverConstant(2, $Constant);
182628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
182638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $Old_Value_Pure = $Old_Value;
182648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my $New_Value_Pure = $New_Value;
182658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/(\W)\s+/$1/g;
18267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Old_Value_Pure=~s/\s+(\W)/$1/g;
18268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/(\W)\s+/$1/g;
18269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $New_Value_Pure=~s/\s+(\W)/$1/g;
182708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18271ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($New_Value_Pure eq "" or $Old_Value_Pure eq "");
18272fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18273ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($New_Value_Pure ne $Old_Value_Pure)
18274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # different values
18275fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(simpleConstant(1, $Old_Value) eq simpleConstant(2, $New_Value))
18276fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # complex values
18277fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18278fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18279fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(computeValue($Old_Value) eq computeValue($New_Value))
18280fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            { # expressions
18281fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next;
18282fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(convert_integer($Old_Value) eq convert_integer($New_Value))
18284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0x0001 and 0x1, 0x1 and 1 equal constants
18285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "0" and $New_Value eq "NULL")
18288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0 => NULL
18289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Old_Value eq "NULL" and $New_Value eq "0")
18292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # NULL => 0
18293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next;
18294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
182958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Changed_Constant"}} = (
18296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Target"=>$Constant,
18297ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "Old_Value"=>$Old_Value,
18298ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                "New_Value"=>$New_Value  );
18299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
183018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    foreach my $Constant (keys(%{$Constants{2}}))
183038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {
183048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(not defined $Constants{1}{$Constant}{"Value"})
183058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
183068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if($SkipConstants{2}{$Constant})
183078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # skipped by the user
183088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
18311fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $Header = $Constants{2}{$Constant}{"Header"})
18312fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
18313fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(not is_target_header($Header, 1)
18314fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not is_target_header($Header, 2))
18315fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                { # user-defined header
18316fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    next;
18317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18318fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
18319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            else {
183208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $New_Value = uncoverConstant(2, $Constant);
183248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not defined $New_Value or $New_Value eq "") {
183258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(constantFilter($Constant, $New_Value, $Level))
183298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            { # separate binary and source problems
183308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next;
183318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
183328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
183338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            %{$CompatProblems_Constants{$Level}{$Constant}{"Added_Constant"}} = (
183348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "Target"=>$Constant,
183358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                "New_Value"=>$New_Value  );
183368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
183378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
18338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub convert_integer($)
18341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Value = $_[0];
18343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Value=~/\A0x[a-f0-9]+\Z/)
183441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # hexadecimal
18345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return hex($Value);
18346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0[0-7]+\Z/)
183481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # octal
18349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Value=~/\A0b[0-1]+\Z/)
183521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # binary
18353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return oct($Value);
18354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
18356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Value;
18357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
183601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols($)
18361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
1836362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my @LibPaths = getSOPaths($LibVersion);
183641693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if($#LibPaths==-1 and not $CheckHeadersOnly)
18365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LibVersion==1)
18367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
18368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
18369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
18370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
18372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "$SLIB_TYPE libraries are not found in ".$Descriptor{$LibVersion}{"Version"});
18373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18375570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
183764b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    foreach my $LibPath (@LibPaths) {
183779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        readSymbols_Lib($LibVersion, $LibPath, 0, "+Weak", 1, 1);
18378570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18379570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18380570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($CheckUndefined)
18381570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18382570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my %UndefinedLibs = ();
18383570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1838474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my @Libs = (keys(%{$Library_Symbol{$LibVersion}}), keys(%{$DepLibrary_Symbol{$LibVersion}}));
1838574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1838674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $LibName (sort @Libs)
18387570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
1838874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(defined $UndefinedSymbols{$LibVersion}{$LibName})
18389570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
1839074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                foreach my $Symbol (keys(%{$UndefinedSymbols{$LibVersion}{$LibName}}))
18391570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if($Symbol_Library{$LibVersion}{$Symbol}
18393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    or $DepSymbol_Library{$LibVersion}{$Symbol})
18394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported by target library
18395fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        next;
18396fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18397fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    if(index($Symbol, '@')!=-1)
18398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    { # exported default symbol version (@@)
18399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Symbol=~s/\@/\@\@/;
18400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        if($Symbol_Library{$LibVersion}{$Symbol}
18401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        or $DepSymbol_Library{$LibVersion}{$Symbol}) {
18402fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            next;
1840374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        }
18404570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18405fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    foreach my $Path (find_SymbolLibs($LibVersion, $Symbol)) {
18406fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $UndefinedLibs{$Path} = 1;
18407fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    }
18408570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18409570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18410570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18411570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($ExtraInfo)
18412570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # extra information for other tools
18413fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my @Paths = sort keys(%UndefinedLibs))
18414570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18415570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $LibString = "";
18416fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                my %Dirs = ();
18417570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach (@Paths)
18418570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
1841974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $KnownLibs{$_} = 1;
18420570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    my ($Dir, $Name) = separate_path($_);
18421570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18422570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(not grep {$Dir eq $_} (@{$SystemPaths{"lib"}})) {
18423fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                        $Dirs{esc($Dir)} = 1;
18424570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18425570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18426570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name = parse_libname($Name, "name", $OStarget);
18427570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Name=~s/\Alib//;
18428570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1842974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $LibString .= " -l$Name";
18430570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18431fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18432fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                foreach my $Dir (sort {$b cmp $a} keys(%Dirs))
18433fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
18434fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $LibString = " -L".esc($Dir).$LibString;
18435fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
18436fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18437570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                writeFile($ExtraInfo."/libs-string", $LibString);
18438570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18439570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
184401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
18441570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1844274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo) {
1844374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/lib-paths", join("\n", sort keys(%KnownLibs)));
1844474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1844574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
184461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(not $CheckHeadersOnly)
184471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
184481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if($#LibPaths!=-1)
184491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
184501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if(not keys(%{$Symbol_Library{$LibVersion}}))
184511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            {
184520d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko                printMsg("WARNING", "the set of public symbols in library(ies) is empty ($LibVersion)");
184531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                printMsg("WARNING", "checking headers only");
184541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                $CheckHeadersOnly = 1;
184551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
184561693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
18457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18458850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1845907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko   # clean memory
18460850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko   %SystemObjects = ();
18461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18463570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Prefix_Lib_Map=(
18464570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by prefix)
18465570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pthread_" => ["libpthread"],
18466570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "g_" => ["libglib-2.0", "libgobject-2.0", "libgio-2.0"],
18467570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cairo_" => ["libcairo"],
18468570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gtk_" => ["libgtk-x11-2.0"],
18469570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "atk_" => ["libatk-1.0"],
18470570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gdk_" => ["libgdk-x11-2.0"],
18471570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "gl" => ["libGL"],
18472570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "glu" => ["libGLU"],
18473570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "popt" => ["libpopt"],
18474570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Py" => ["libpython"],
18475570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "jpeg_" => ["libjpeg"],
18476570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "BZ2_" => ["libbz2"],
18477570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Fc" => ["libfontconfig"],
18478570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "Xft" => ["libXft"],
18479570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SSL_" => ["libssl"],
18480570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sem_" => ["libpthread"],
18481570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "snd_" => ["libasound"],
18482570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "art_" => ["libart_lgpl_2"],
18483570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dbus_g" => ["libdbus-glib-1"],
18484570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "GOMP_" => ["libgomp"],
18485570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "omp_" => ["libgomp"],
18486570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cms" => ["liblcms"]
18487570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18488570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18489570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Pattern_Lib_Map=(
18490570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "SL[a-z]" => ["libslang"]
18491570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18492570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18493570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkomy %Symbol_Lib_Map=(
18494570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko # symbols for autodetecting library dependencies (by name)
18495570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "pow" => "libm",
18496570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "fmod" => "libm",
18497570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "sin" => "libm",
18498570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "floor" => "libm",
18499570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "cos" => "libm",
18500570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "dlopen" => "libdl",
18501570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "deflate" => "libz",
18502570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "inflate" => "libz",
18503570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "move_panel" => "libpanel",
18504570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "XOpenDisplay" => "libX11",
18505570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    "resize_term" => "libncurses",
185068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "clock_gettime" => "librt",
185078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    "crypt" => "libcrypt"
18508570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko);
18509570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18510570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub find_SymbolLibs($$)
18511570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18512570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Symbol) = @_;
18513570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18514570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(index($Symbol, "g_")==0 and $Symbol=~/[A-Z]/)
18515570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # debug symbols
18516570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return ();
18517570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18518570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18519570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %Paths = ();
18520570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18521570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $LibName = $Symbol_Lib_Map{$Symbol})
18522570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18523570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18524570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Paths{$Path} = 1;
18525570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18526570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18527570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18528570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(my $SymbolPrefix = getPrefix($Symbol))
18529570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
18530570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(defined $Cache{"find_SymbolLibs"}{$SymbolPrefix}) {
18531570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return @{$Cache{"find_SymbolLibs"}{$SymbolPrefix}};
18532570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18533570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18534570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18535570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18536570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(defined $Prefix_Lib_Map{$SymbolPrefix})
18537570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18538570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $LibName (@{$Prefix_Lib_Map{$SymbolPrefix}})
18539570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18540570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18541570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18542570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18543570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18544570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18545570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18546570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18547570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18548570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18549570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Prefix (sort keys(%Pattern_Lib_Map))
18550570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
18551570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Symbol=~/\A$Prefix/)
18552570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18553570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    foreach my $LibName (@{$Pattern_Lib_Map{$Prefix}})
18554570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
18555570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(my $Path = get_LibPath($LibVersion, $LibName.".".$LIB_EXT)) {
18556570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                            $Paths{$Path} = 1;
18557570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
18558570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18559570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18560570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18561570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18562570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18563570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not keys(%Paths))
18564570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18565570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($SymbolPrefix)
18566570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # try to find a library by symbol prefix
18567570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($SymbolPrefix eq "inotify" and
18568570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                index($Symbol, "\@GLIBC")!=-1)
18569570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18570570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath($LibVersion, "libc.$LIB_EXT")) {
18571570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18572570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18573570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18574570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                else
18575570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
18576570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(my $Path = get_LibPath_Prefix($LibVersion, $SymbolPrefix)) {
18577570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $Paths{$Path} = 1;
18578570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
18579570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
18580570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
18581570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18582570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18583570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my @Paths = keys(%Paths)) {
18584570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            $Cache{"find_SymbolLibs"}{$SymbolPrefix} = \@Paths;
18585570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18586570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18587570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return keys(%Paths);
18588570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18589570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18590570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub get_LibPath_Prefix($$)
18591570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18592570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my ($LibVersion, $Prefix) = @_;
18593570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18594570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix = lc($Prefix);
18595570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Prefix=~s/[_]+\Z//g;
18596570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18597570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach ("-2", "2", "-1", "1", "")
18598570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # libgnome-2.so
18599570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libxml2.so
18600570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko      # libdbus-1.so
18601570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(my $Path = get_LibPath($LibVersion, "lib".$Prefix.$_.".".$LIB_EXT)) {
18602570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            return $Path;
18603570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
18604570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18605570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18606570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18607570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
18608570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub getPrefix($)
18609570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
18610570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $Str = $_[0];
18611570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Str=~/\A([_]*[A-Z][a-z]{1,5})[A-Z]/)
18612570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XmuValidArea: Xmu
18613570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18614570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18615570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]+)[A-Z]/)
18616570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # snfReadFont: snf
18617570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18618570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18619570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[A-Z]{2,})[A-Z][a-z]+([A-Z][a-z]+|\Z)/)
18620570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # XRRTimes: XRR
18621570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18622570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18623570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z]{1,2}\d+)[a-z\d]*_[a-z]+/i)
18624570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # H5HF_delete: H5
18625570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18626570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18627570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A([_]*[a-z0-9]{2,}_)[a-z]+/i)
18628570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # alarm_event_add: alarm_
18629570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18630570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18631570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    elsif($Str=~/\A(([a-z])\2{1,})/i)
18632570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # ffopen
18633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        return $1;
18634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
18635570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return "";
18636570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
18637570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
186381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub getSymbolSize($$)
186391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{ # size from the shared library
186401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    my ($Symbol, $LibVersion) = @_;
186411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0 if(not $Symbol);
186421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    if(defined $Symbol_Library{$LibVersion}{$Symbol}
186431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    and my $LibName = $Symbol_Library{$LibVersion}{$Symbol})
186441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
186451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        if(defined $Library_Symbol{$LibVersion}{$LibName}{$Symbol}
186461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        and my $Size = $Library_Symbol{$LibVersion}{$LibName}{$Symbol})
186471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
186481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($Size<0) {
186491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                return -$Size;
18650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18652ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
186531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    return 0;
18654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1865607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub canonifyName($$)
18657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # make TIFFStreamOpen(char const*, std::basic_ostream<char, std::char_traits<char> >*)
18658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # to be TIFFStreamOpen(char const*, std::basic_ostream<char>*)
1865907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    my ($Name, $Type) = @_;
1866007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1866107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # single
1866207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    while($Name=~/([^<>,]+),\s*$DEFAULT_STD_PARMS<([^<>,]+)>\s*/ and $1 eq $3)
18663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18664850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        my $P = $1;
1866507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $Name=~s/\Q$P\E,\s*$DEFAULT_STD_PARMS<\Q$P\E>\s*/$P/g;
18666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1866707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1866807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    # double
1866907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if($Name=~/$DEFAULT_STD_PARMS/)
1867007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    {
18671e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        if($Type eq "S")
1867207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1867307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortName, $FuncParams) = split_Signature($Name);
1867407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1867507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            foreach my $FParam (separate_Params($FuncParams, 0, 0))
1867607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
1867707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                if(index($FParam, "<")!=-1)
1867807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                {
1867907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $FParam=~s/>([^<>]+)\Z/>/; # remove quals
1868007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    my $FParam_N = canonifyName($FParam, "T");
1868107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    if($FParam_N ne $FParam) {
1868207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                        $Name=~s/\Q$FParam\E/$FParam_N/g;
1868307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    }
1868407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1868507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1868607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1868707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        elsif($Type eq "T")
1868807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        {
1868907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my ($ShortTmpl, $TmplParams) = template_Base($Name);
1869007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1869107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            my @TParams = separate_Params($TmplParams, 0, 0);
18692e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko            if($#TParams>=1)
1869307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            {
18694e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                my $FParam = $TParams[0];
18695e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                foreach my $Pos (1 .. $#TParams)
18696e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                {
18697e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    my $TParam = $TParams[$Pos];
18698e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    if($TParam=~/\A$DEFAULT_STD_PARMS<\Q$FParam\E\s*>\Z/) {
18699e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                        $Name=~s/\Q$FParam, $TParam\E\s*/$FParam/g;
18700e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko                    }
1870107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1870207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            }
1870307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        }
1870407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    }
18705e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    if($Type eq "S") {
18706e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko        return formatName($Name, "S");
18707e3d6bf0024b78f4214f57d45b592291aa5fbf8c4Andrey Ponomarenko    }
18708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
18709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18711dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenkosub translateSymbols(@)
18712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = pop(@_);
1871462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my (@MnglNames1, @MnglNames2, @UnmangledNames) = ();
187159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $Symbol (sort @_)
18716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
187179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Symbol, "_Z")==0)
18718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
187199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            next if($tr_name{$Symbol});
187209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Symbol=~s/[\@\$]+(.*)\Z//;
187219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames1, $Symbol);
18722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18723570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        elsif(index($Symbol, "?")==0)
18724570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
18725570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            next if($tr_name{$Symbol});
187269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            push(@MnglNames2, $Symbol);
18727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
18729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # not mangled
187309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $tr_name{$Symbol} = $Symbol;
187319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name_gcc{$Symbol} = $Symbol;
187329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $mangled_name{$LibVersion}{$Symbol} = $Symbol;
18733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames1 > -1)
18736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC names
1873762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames1));
18738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames1)
18739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1874062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1874162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
1874272930b9bbe1284ca8eee0f5a2728d5bf094400e5Andrey Ponomarenko                $tr_name{$MnglName} = canonifyName($Unmangled, "S");
1874362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $mangled_name_gcc{$tr_name{$MnglName}}) {
1874462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $mangled_name_gcc{$tr_name{$MnglName}} = $MnglName;
1874562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
187469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($MnglName, "_ZTV")==0
1874762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                and $tr_name{$MnglName}=~/vtable for (.+)/)
1874862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # bind class name and v-table symbol
1874962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    my $ClassName = $1;
1875062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $ClassVTable{$ClassName} = $MnglName;
1875162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $VTableClass{$MnglName} = $ClassName;
1875262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
18753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#MnglNames2 > -1)
18757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # MSVC names
1875862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        @UnmangledNames = reverse(unmangleArray(@MnglNames2));
18759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $MnglName (@MnglNames2)
18760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
1876162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $Unmangled = pop(@UnmangledNames))
1876262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
187639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $tr_name{$MnglName} = formatName($Unmangled, "S");
1876462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $mangled_name{$LibVersion}{$tr_name{$MnglName}} = $MnglName;
1876562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
18766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%tr_name;
18769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol($$$)
18772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Deps) = @_;
18774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(link_symbol_internal($Symbol, $RunWith, \%Symbol_Library)) {
18775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Deps eq "+Deps")
18778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check the dependencies
1877962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(link_symbol_internal($Symbol, $RunWith, \%DepSymbol_Library)) {
18780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
18786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub link_symbol_internal($$$)
18787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Symbol, $RunWith, $Where) = @_;
18789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $Where or not $Symbol);
18790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Where->{$RunWith}{$Symbol})
18791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # the exact match by symbol name
18792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
18793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VSym = $SymVer{$RunWith}{$Symbol})
18795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # indirect symbol version, i.e.
18796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # foo_old and its symlink foo@v (or foo@@v)
187979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # foo_old may be in symtab table
18798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$VSym}) {
18799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
188021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Sym, $Spec, $Ver) = separate_symbol($Symbol);
18803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Sym and $Ver)
18804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # search for the symbol with the same version
18805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # or without version
18806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym})
18807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo@v|foo@@v
18808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo
18809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@".$Ver})
18812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@@v
18813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@v
18814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Where->{$RunWith}{$Sym."\@\@".$Ver})
18817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # old: foo|foo@v
18818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # new: foo@@v
18819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
18820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
18823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
188251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenkosub readSymbols_App($)
18826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
18827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Path = $_[0];
188289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $Path);
18829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Imported = ();
18830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "macos")
18831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1883207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
1883307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if(not $NM) {
1883407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
18835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1883607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        open(APP, "$NM -g \"$Path\" 2>\"$TMP_DIR/null\" |");
188379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
188389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
1883907aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ U _([\w\$]+)\s*\Z/) {
18840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18845ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OSgroup eq "windows")
18846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
18848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
18849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin.exe\"");
18850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18851a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        open(APP, "$DumpBinCmd /IMPORTS \"$Path\" 2>\"$TMP_DIR/null\" |");
188529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        while(<APP>)
188539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
18854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\s*\w+\s+\w+\s+\w+\s+([\w\?\@]+)\s*/) {
18855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                push(@Imported, $1);
18856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
18861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
18862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
18863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
18864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
18865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18866f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        open(APP, "$ReadelfCmd -Ws \"$Path\" 2>\"$TMP_DIR/null\" |");
188679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
18868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<APP>)
18869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
188709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(defined $symtab)
188719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # do nothing with symtab
188729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($_, "'.dynsym'")!=-1)
188739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # dynamic table
188749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = undef;
188759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
18876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
188779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(index($_, "'.symtab'")!=-1)
188789927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # symbol table
188799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $symtab = 1;
18880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
188819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            elsif(my @Info = readline_ELF($_))
18882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
188839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my ($Ndx, $Symbol) = ($Info[5], $Info[6]);
188849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
188859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                { # only imported symbols
188869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    push(@Imported, $Symbol);
18887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
18888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
18889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
18890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(APP);
18891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
18892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return @Imported;
18893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
188959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_BIND = map {$_=>1} (
188969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "WEAK",
188979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "GLOBAL"
188989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
188999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_TYPE = map {$_=>1} (
189019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "FUNC",
189029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "IFUNC",
189039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "OBJECT",
189049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "COMMON"
189059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
189069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkomy %ELF_VIS = map {$_=>1} (
189089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "DEFAULT",
189099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "PROTECTED"
189109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko);
189119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
18912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readline_ELF($)
189139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{ # read the line of 'readelf' output corresponding to the symbol
189149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my @Info = split(/\s+/, $_[0]);
189159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  Num:   Value      Size Type   Bind   Vis       Ndx  Name
189169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    #  3629:  000b09c0   32   FUNC   GLOBAL DEFAULT   13   _ZNSt12__basic_fileIcED1Ev@@GLIBCXX_3.4
18917fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    #  135:   00000000    0   FUNC   GLOBAL DEFAULT   UND  av_image_fill_pointers@LIBAVUTIL_52 (3)
189189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # spaces
189199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    shift(@Info); # num
18920fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
18921fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($#Info==7)
18922fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # UND SYMBOL (N)
18923fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($Info[7]=~/\(\d+\)/) {
18924fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            pop(@Info);
18925fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
18926fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
18927fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
189289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($#Info!=6)
189299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # other lines
189309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
189319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1893274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    return () if(not defined $ELF_TYPE{$Info[2]} and $Info[5] ne "UND");
189339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_BIND{$Info[3]});
189349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not defined $ELF_VIS{$Info[4]});
189359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Info[5] eq "ABS" and $Info[0]=~/\A0+\Z/)
189369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # 1272: 00000000     0 OBJECT  GLOBAL DEFAULT  ABS CXXABI_1.3
189379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return ();
189389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OStarget eq "symbian")
189409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # _ZN12CCTTokenType4NewLE4TUid3RFs@@ctfinder{000a0000}[102020e5].dll
189419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Info[6], "_._.absent_export_")!=-1)
189429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # "_._.absent_export_111"@@libstdcpp{00010001}[10282872].dll
18943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return ();
18944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
189459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[6]=~s/\@.+//g; # remove version
18946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
189479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(index($Info[2], "0x") == 0)
189489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # size == 0x3d158
189499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Info[2] = hex($Info[2]);
189509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return @Info;
18952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
18953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
189549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath($$)
189551693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko{
189569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
189579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $LibVersion or not $Name);
189589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"get_LibPath"}{$LibVersion}{$Name}) {
189599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_LibPath"}{$LibVersion}{$Name};
189601693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
189619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"get_LibPath"}{$LibVersion}{$Name} = get_LibPath_I($LibVersion, $Name));
189629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
189639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
189649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_LibPath_I($$)
189659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
189669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Name) = @_;
189679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(is_abs($Name))
189681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    {
189699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Name)
189709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # absolute path
189719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return $Name;
189721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
189739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        else
189749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # broken
189759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return "";
189769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
189779927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1897807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredObjects{$LibVersion}{$Name})
189799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1898007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredObjects{$LibVersion}{$Name};
189819927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1898207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    if(defined $RegisteredSONAMEs{$LibVersion}{$Name})
189839927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # registered paths
1898407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        return $RegisteredSONAMEs{$LibVersion}{$Name};
189859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
189869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $DefaultPath = $DyLib_DefaultPath{$Name})
189879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # ldconfig default paths
189889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $DefaultPath;
189899927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18990570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Dir (@DefaultLibPaths, @{$SystemPaths{"lib"}})
189919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # search in default linker directories
189929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko      # and then in all system paths
189939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(-f $Dir."/".$Name) {
1899474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            return join_P($Dir,$Name);
189951693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
189969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
18997e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not defined $Cache{"checkSystemFiles"}) {
18998e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        checkSystemFiles();
18999e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
190009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my @AllObjects = keys(%{$SystemObjects{$Name}})) {
190019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $AllObjects[0];
190029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
190039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $ShortName = parse_libname($Name, "name+ext", $OStarget))
190049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($ShortName ne $Name)
190061693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # FIXME: check this case
190079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my $Path = get_LibPath($LibVersion, $ShortName)) {
190089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $Path;
190099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
190101693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
190111693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
190129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    # can't find
190139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "";
190141693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko}
190151693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
190169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub readSymbols_Lib($$$$$$)
19017ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
190189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($LibVersion, $Lib_Path, $IsNeededLib, $Weak, $Deps, $Vers) = @_;
190199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(not $LibVersion or not $Lib_Path);
1902074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1902174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Real_Path = realpath($Lib_Path);
1902274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1902374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not $Real_Path)
1902474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # broken link
1902574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        return ();
1902674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1902774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1902874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    my $Lib_Name = get_filename($Real_Path);
1902974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
19030fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ExtraInfo)
19031fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
1903274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $KnownLibs{$Real_Path} = 1;
19033fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $KnownLibs{$Lib_Path} = 1; # links
1903474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1903574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
190369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($IsNeededLib)
190379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($CheckedDyLib{$LibVersion}{$Lib_Name}) {
190399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ();
190409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
190419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
190429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return () if(isCyclical(\@RecurLib, $Lib_Name) or $#RecurLib>=1);
19043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $CheckedDyLib{$LibVersion}{$Lib_Name} = 1;
1904462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
190459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($CheckImpl)
190469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
190479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib) {
190489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            getImplementations($LibVersion, $Lib_Path);
190499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
190501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1905162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
19052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    push(@RecurLib, $Lib_Name);
19053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my (%Value_Interface, %Interface_Value, %NeededLib) = ();
1905457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    my $Lib_ShortName = parse_libname($Lib_Name, "name+ext", $OStarget);
1905557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko
1905657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(not $IsNeededLib)
1905757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    { # special cases: libstdc++ and libc
1905857a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        if(my $ShortName = parse_libname($Lib_Name, "short", $OStarget))
1905957a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        {
1906057a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            if($ShortName eq "libstdc++")
1906157a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libstdc++.so.6
1906257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $STDCXX_TESTING = 1;
1906357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
1906457a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            elsif($ShortName eq "libc")
1906557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            { # libc-2.11.3.so
1906657a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                $GLIBC_TESTING = 1;
1906757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko            }
19068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19070dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    my $DebugPath = "";
19071a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Debug and not $DumpSystem)
190721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # debug mode
19073dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $DebugPath = $DEBUG_PATH{$LibVersion}."/libs/".get_filename($Lib_Path).".txt";
190741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mkpath(get_dirname($DebugPath));
190751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
19076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "macos")
19077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Mac OS X: *.dylib, *.a
1907807aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        my $NM = get_CmdPath("nm");
190794b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        if(not $NM) {
190804b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"nm\"");
19081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1908207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        $NM .= " -g \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19083a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
190841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
190851693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
1908607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            system($NM." >\"$DebugPath\"");
190871693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
190881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
190891693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
190901693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
1909107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            open(LIB, $NM." |");
190921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
19093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19095570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if($CheckUndefined)
19096570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
19097570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(not $IsNeededLib)
19098570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
19099570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if(/ U _([\w\$]+)\s*\Z/)
19100570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
1910174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $UndefinedSymbols{$LibVersion}{$Lib_Name}{$1} = 0;
19102570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        next;
19103570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19104570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
19105570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
19106570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
1910707aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            if(/ [STD] _([\w\$]+)\s*\Z/)
19108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19109570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my $Symbol = $1;
1911062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1911162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1911257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1911362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
19114570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
19115570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
1911662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1911862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19120570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
19121570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = 1;
191229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
191239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
19124570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
191259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
191269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CheckObjectsOnly
19129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $LibVersion==1) {
19130570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $CheckedSymbols{"Binary"}{$Symbol} = 1;
19131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
1913607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
191379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
191389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
191399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
191409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
1914107aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
1914207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                my $OtoolCmd = get_CmdPath("otool");
191434b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                if(not $OtoolCmd) {
191444b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                    exitStatus("Not_Found", "can't find \"otool\"");
1914507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                }
1914607aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
191479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$OtoolCmd -L \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
191489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
191499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
191509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([\/\\].+\.$LIB_EXT)\s*/
191519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
191529927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{$1} = 1;
191539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
191559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($OStarget eq "windows")
19160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Windows *.dll, *.lib
19161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DumpBinCmd = get_CmdPath("dumpbin");
19162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DumpBinCmd) {
19163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"dumpbin\"");
19164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
191651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DumpBinCmd .= " /EXPORTS \"".$Lib_Path."\" 2>$TMP_DIR/null";
19166a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
191671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
191681693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19169a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            system($DumpBinCmd." >\"$DebugPath\"");
191701693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
191711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
191721693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
191731693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
191741693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DumpBinCmd." |");
191751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
19176ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 1197 4AC 0000A620 SetThreadStackGuarantee
19178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 1198 4AD          SetThreadToken (forwarded to ...)
19179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # 3368 _o2i_ECPublicKey
19180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(/\A\s*\d+\s+[a-f\d]+\s+[a-f\d]+\s+([\w\?\@]+)\s*\Z/i
19181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+[a-f\d]+\s+([\w\?\@]+)\s*\(\s*forwarded\s+/
19182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            or /\A\s*\d+\s+_([\w\?\@]+)\s*\Z/)
19183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic, static and forwarded symbols
19184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $realname = $1;
1918562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1918662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1918757a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1918862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
1918962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$realname} = $Lib_Name;
1919062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
1919162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1919362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$realname} = $Lib_Name;
19196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$realname} = 1;
191979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
191989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
191999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($realname, "_Z")==0 or index($realname, "?")==0) {
192009927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
192019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CheckObjectsOnly
19204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $LibVersion==1) {
192051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                        $CheckedSymbols{"Binary"}{$realname} = 1;
19206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        close(LIB);
19211f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
192129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Deps)
192139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
192149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
192159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            { # dependencies
192169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                open(LIB, "$DumpBinCmd /DEPENDENTS \"$Lib_Path\" 2>\"$TMP_DIR/null\" |");
192179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                while(<LIB>)
192189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                {
192199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(/\s*([^\s]+?\.$LIB_EXT)\s*/i
192209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    and $1 ne $Lib_Path) {
192219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $NeededLib{path_format($1, $OSgroup)} = 1;
192229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    }
19223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                close(LIB);
19225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # Unix; *.so, *.a
19230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Symbian: *.dso, *.lib
19231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $ReadelfCmd = get_CmdPath("readelf");
19232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ReadelfCmd) {
19233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find \"readelf\"");
19234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19235f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        my $Cmd = $ReadelfCmd." -Ws \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19236a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if($DebugPath)
192371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # debug mode
192381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko          # write to file
19239f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            system($Cmd." >\"$DebugPath\"");
192401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            open(LIB, $DebugPath);
192411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
192421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        else
192431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        { # write to pipe
19244f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
192451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
192469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $symtab = undef; # indicates that we are processing 'symtab' section of 'readelf' output
19247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        while(<LIB>)
19248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($LIB_TYPE eq "dynamic")
19250ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # dynamic library specifics
192519927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(defined $symtab)
1925262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
192539927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if(index($_, "'.dynsym'")!=-1)
1925462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    { # dynamic table
192559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $symtab = undef;
1925662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
192579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    # do nothing with symtab
192589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    next;
19259ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                elsif(index($_, "'.symtab'")!=-1)
19261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # symbol table
192629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $symtab = 1;
19263ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19265ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
192669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if(my ($Value, $Size, $Type, $Bind, $Vis, $Ndx, $Symbol) = readline_ELF($_))
19267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # read ELF entry
192689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Ndx eq "UND")
19269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # ignore interfaces that are imported from somewhere else
19270570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($CheckUndefined)
19271570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    {
19272570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        if(not $IsNeededLib) {
1927374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                            $UndefinedSymbols{$LibVersion}{$Lib_Name}{$Symbol} = 0;
19274570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        }
19275570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
19276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
19277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19278c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                if($Bind eq "WEAK")
19279c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                {
1928007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                    $WeakSymbols{$LibVersion}{$Symbol} = 1;
19281c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    if($Weak eq "-Weak")
19282c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    { # skip WEAK symbols
19283c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                        next;
19284c593c3258dee0ca19a4f824dd1892bd20b3e4bceAndrey Ponomarenko                    }
19285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
192869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                my $Short = $Symbol;
192879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                $Short=~s/\@.+//g;
192889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if($Type eq "OBJECT")
19289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # global data
19290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Symbol} = $Size;
19291fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $GlobalDataObject{$LibVersion}{$Short} = $Size;
19292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1929362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($IsNeededLib)
1929462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
1929557a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko                    if(not defined $RegisteredObjects_Short{$LibVersion}{$Lib_ShortName})
1929662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
192979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
192989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $DepLibrary_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
1929962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
19300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
1930162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
19302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
193039927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
193049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    $Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol} = ($Type eq "OBJECT")?-$Size:1;
193059927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($Vers)
193069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
193079927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($LIB_EXT eq "so")
193089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        { # value
193099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Interface_Value{$LibVersion}{$Symbol} = $Value;
193109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $Value_Interface{$LibVersion}{$Value}{$Symbol} = 1;
193119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
193139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    if($COMMON_LANGUAGE{$LibVersion} ne "C++")
193149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    {
193159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
193169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            setLanguage($LibVersion, "C++");
193179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19318ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19319ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($CheckObjectsOnly
19320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    and $LibVersion==1) {
193219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        $CheckedSymbols{"Binary"}{$Symbol} = 1;
19322ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19323ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19324ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19325f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        }
19326f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        close(LIB);
19327f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19328f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        if($Deps and $LIB_TYPE eq "dynamic")
19329f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko        { # dynamic library specifics
19330f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            $Cmd = $ReadelfCmd." -Wd \"$Lib_Path\" 2>\"$TMP_DIR/null\"";
19331f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            open(LIB, $Cmd." |");
19332f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19333f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            while(<LIB>)
19334f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            {
19335f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if(/NEEDED.+\[([^\[\]]+)\]/)
19336f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # dependencies:
19337f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                  # 0x00000001 (NEEDED) Shared library: [libc.so.6]
19338f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $NeededLib{$1} = 1;
1933962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
1934062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19341f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
19342f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko            close(LIB);
19343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Vers)
193469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    {
193479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not $IsNeededLib and $LIB_EXT eq "so")
193489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # get symbol versions
19349fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my %Found = ();
19350fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19351fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # by value
1935274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
193549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
193559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(my $Value = $Interface_Value{$LibVersion}{$Symbol})
19356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
193579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    foreach my $Symbol_SameValue (keys(%{$Value_Interface{$LibVersion}{$Value}}))
19358a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    {
193599927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        if($Symbol_SameValue ne $Symbol
193609927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        and index($Symbol_SameValue,"\@")==-1)
193619927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        {
193629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            $SymVer{$LibVersion}{$Symbol_SameValue} = $Symbol;
19363fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                            $Found{$Symbol} = 1;
193649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                            last;
193659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
19366a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko                    }
19367fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19368fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19369fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19370fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # default
19371fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19372fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19373fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19374fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@\@")==-1);
19375fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19376fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@\@/
19377fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19378fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19379fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19380fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19381fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
19382fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
19383fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19384fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            # non-default
19385fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
19386fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
19387fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(defined $Found{$Symbol});
19388fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                next if(index($Symbol,"\@")==-1);
19389fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19390fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if($Symbol=~/\A([^\@]*)\@([^\@]*)/
19391fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                and not $SymVer{$LibVersion}{$1})
19392fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                {
19393fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $SymVer{$LibVersion}{$1} = $Symbol;
19394fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $Found{$Symbol} = 1;
19395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
193999927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($Deps)
19400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194019927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach my $DyLib (sort keys(%NeededLib))
194029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19403fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Library_Needed{$LibVersion}{$Lib_Name}{get_filename($DyLib)} = 1;
19404fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1940574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(my $DepPath = get_LibPath($LibVersion, $DyLib))
1940674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
1940774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if(not $CheckedDyLib{$LibVersion}{get_filename($DepPath)}) {
1940874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    readSymbols_Lib($LibVersion, $DepPath, 1, "+Weak", $Deps, $Vers);
1940974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
194109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    pop(@RecurLib);
19414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Library_Symbol{$LibVersion};
19415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
194179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes($)
19418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Prefixes = ();
194209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    get_prefixes_I([$_[0]], \%Prefixes);
194219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return keys(%Prefixes);
194229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
194239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
194249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub get_prefixes_I($$)
194259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
194269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach my $P (@{$_[0]})
19427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
194289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my @Parts = reverse(split(/[\/\\]+/, $P));
194299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        my $Name = $Parts[0];
194309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        foreach (1 .. $#Parts)
194319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
194329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $_[1]->{$Name}{$P} = 1;
194339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            last if($_>4 or $Parts[$_] eq "include");
194349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $Name = $Parts[$_].$SLASH.$Name;
194359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19439e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenkosub checkSystemFiles()
19440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19441e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    $Cache{"checkSystemFiles"} = 1;
19442e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @SysHeaders = ();
19444e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19445e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    foreach my $DevelPath (@{$SystemPaths{"lib"}})
19446ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19447ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not -d $DevelPath);
19448e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19449e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Files = cmd_find($DevelPath);
19450e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19451e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        if(not $CheckObjectsOnly)
19452e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        {
19453e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            # search for headers in /usr/lib
1945413bb033145ee96b66128046473bfa6b238cf0a48Andrey Ponomarenko            my @Headers = grep { /\.h(pp|xx)?\Z|\/include\// } @Files;
1945513bb033145ee96b66128046473bfa6b238cf0a48Andrey Ponomarenko            @Headers = grep { not /\/(gcc|jvm|syslinux|kbd|parrot|xemacs|perl|llvm)/ } @Headers;
1945613bb033145ee96b66128046473bfa6b238cf0a48Andrey Ponomarenko            push(@SysHeaders, @Headers);
19457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19458e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19459e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        # search for libraries in /usr/lib (including symbolic links)
19460e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        my @Libs = grep { /\.$LIB_EXT[0-9.]*\Z/ } @Files;
19461e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $Path (@Libs)
194629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
19463e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            my $N = get_filename($Path);
19464e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{$N}{$Path} = 1;
19465e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            $SystemObjects{parse_libname($N, "name+ext", $OStarget)}{$Path} = 1;
19466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19468e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko
19469e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if(not $CheckObjectsOnly)
19470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19471e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        foreach my $DevelPath (@{$SystemPaths{"include"}})
19472e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        {
19473e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            next if(not -d $DevelPath);
19474e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            # search for all header files in the /usr/include
19475e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            # with or without extension (ncurses.h, QtCore, ...)
19476e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            push(@SysHeaders, cmd_find($DevelPath,"f"));
19477e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            foreach my $Link (cmd_find($DevelPath,"l"))
19478e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            { # add symbolic links
19479e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                if(-f $Link) {
19480e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                    push(@SysHeaders, $Link);
19481e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko                }
19482e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko            }
19483ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19484e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        get_prefixes_I(\@SysHeaders, \%SystemHeaders);
19485ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19486ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19487ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
1948862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub getSOPaths($)
19489ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19490ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
194914b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    my @Paths = ();
19492ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dest (split(/\s*\n\s*/, $Descriptor{$LibVersion}{"Libs"}))
19493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Dest) {
19495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Dest\'");
19496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19497fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Dest = get_abs_path($Dest);
19498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @SoPaths_Dest = getSOPaths_Dest($Dest, $LibVersion);
19499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach (@SoPaths_Dest) {
195004b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            push(@Paths, $_);
19501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
195034b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    return sort @Paths;
19504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
195068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipLib($$)
19507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
19509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
195101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
195111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$Name}) {
19512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
195141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $ShortName = parse_libname($Name, "name+ext", $OStarget);
19515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipLibs{$LibVersion}{"Name"}{$ShortName}) {
19516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1;
19517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Dir (keys(%{$SkipLibs{$LibVersion}{"Path"}}))
19519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Path=~/\Q$Dir\E([\/\\]|\Z)/) {
19521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
195241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $P (keys(%{$SkipLibs{$LibVersion}{"Pattern"}}))
19525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
195261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($Name=~/$P/) {
19527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
195291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($P=~/[\/\\]/ and $Path=~/$P/) {
19530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
19531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
195368f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub specificHeader($$)
195378f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
195388f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my ($Header, $Spec) = @_;
195398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Header);
195408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Spec eq "windows")
195428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    {# MS Windows
195438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[._-])(win|wince|wnt)(\d\d|[._-]|\Z)/i);
195448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/([._-]w|win)(32|64)/i);
195458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(Win|Windows)[A-Z]/);
195468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/\A(w|win|windows)(32|64|\.)/i);
195478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
195488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win32",
195498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win64",
195508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "win",
195518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "windows",
195528f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "msvcrt"
195538f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        ); # /gsf-win32/
195548f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
195558f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Header=~/[\/\\](|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
195568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
195578f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195588f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    elsif($Spec eq "macos")
195598f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # Mac OS
195608f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/(\A|[_-])mac[._-]/i);
195618f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
195628f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195638f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
195648f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
195658f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195668f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenkosub skipAlienHeader($)
195678f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko{
195688f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Path = $_[0];
195698f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Name = get_filename($Path);
195708f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Dir = get_dirname($Path);
195718f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195728f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/2/)
195738f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 2 - skip internal headers
195748f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Terms = (
195758f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "p",
195768f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
195778f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "int",
195788f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
195798f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "implementation",
195808f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
195818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
195828f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
195838f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
195848f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
195858f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test",
195868f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "gen"
195878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
195888f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
195898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        my @Dirs = (
195908f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "private",
195918f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "priv",
195928f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "port",
195938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "impl",
195948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "internal",
195958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "detail",
195968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "details",
195978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "old",
195988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compat",
195998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "debug",
196008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "config",
196018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "compiler",
196028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "platform",
196038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            "test"
196048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        );
196058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $TERMs = join("|", @Terms)) {
196078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Name=~/(\A|[._-])($TERMs)([._-]|\Z)/i);
196088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196098f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(my $DIRs = join("|", @Dirs)) {
196108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return 1 if($Dir=~/(\A|[\/\\])(|[^\/\\]+[._-])($DIRs)(|[._-][^\/\\]+)([\/\\]|\Z)/i);
196118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 1 if($Name=~/[a-z](Imp|Impl|I|P)(\.|\Z)/);
196148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
196158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerance=~/1/)
196178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # 1 - skip non-Linux headers
196188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "windows")
196198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
196208f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "windows")) {
196218f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
196228f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
196238f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196248f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup ne "macos")
196258f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        {
196268f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(specificHeader($Path, "macos")) {
196278f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                return 1;
196288f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
196298f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196308f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
196318f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
196328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    # valid
196338f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return 0;
196348f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko}
196358f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
1963662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader($$)
1963762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko{
1963862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
1963962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 1 if(not $Path or not $LibVersion);
1964062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"skipHeader"}{$Path}) {
1964162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"skipHeader"}{$Path};
1964262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
196438f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(defined $Tolerance and $Tolerance=~/1|2/)
196448f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # --tolerant
196458f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if(skipAlienHeader($Path)) {
196468f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            return ($Cache{"skipHeader"}{$Path} = 1);
196478f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        }
196488f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
196498f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not keys(%{$SkipHeaders{$LibVersion}})) {
196508f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        return 0;
196518f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
1965262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"skipHeader"}{$Path} = skipHeader_I(@_));
1965362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko}
1965462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
1965562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub skipHeader_I($$)
19656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # returns:
19657ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  1 - if header should NOT be included and checked
19658ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  #  2 - if header should NOT be included, but should be checked
19659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
196601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Name = get_filename($Path);
196611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(my $Kind = $SkipHeaders{$LibVersion}{"Name"}{$Name}) {
19662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Kind;
19663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19664f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $D (sort {$SkipHeaders{$LibVersion}{"Path"}{$a} cmp $SkipHeaders{$LibVersion}{"Path"}{$b}}
19665f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Path"}}))
19666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
196679927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(index($Path, $D)!=-1)
196689927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        {
196699927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($Path=~/\Q$D\E([\/\\]|\Z)/) {
196709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                return $SkipHeaders{$LibVersion}{"Path"}{$D};
196719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            }
19672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19674f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    foreach my $P (sort {$SkipHeaders{$LibVersion}{"Pattern"}{$a} cmp $SkipHeaders{$LibVersion}{"Pattern"}{$b}}
19675f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    keys(%{$SkipHeaders{$LibVersion}{"Pattern"}}))
19676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
1967762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(my $Kind = $SkipHeaders{$LibVersion}{"Pattern"}{$P})
1967862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
1967962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Name=~/$P/) {
1968062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1968162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
1968262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($P=~/[\/\\]/ and $Path=~/$P/) {
1968362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                return $Kind;
1968462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
19685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
196878f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
19688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
196919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject_Dir($$)
19692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dir, $LibVersion) = @_;
19694570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(grep {$_ eq $Dir} @{$SystemPaths{"lib"}})
19695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # system directory
19696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
196989927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($RegisteredObject_Dirs{$LibVersion}{$Dir})
19699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # already registered
19700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
19701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Path (find_libs($Dir,"",1))
19703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(ignore_path($Path));
197058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        next if(skipLib($Path, $LibVersion));
197069927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Path, $LibVersion);
19707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
197089927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $RegisteredObject_Dirs{$LibVersion}{$Dir} = 1;
197099927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
197109927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
197119927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub registerObject($$)
197129927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
197139927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Path, $LibVersion) = @_;
197149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Name = get_filename($Path);
1971507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko    $RegisteredObjects{$LibVersion}{$Name} = $Path;
197162768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    if($OSgroup=~/linux|bsd/i)
197172768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko    {
197182768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        if(my $SONAME = getSONAME($Path)) {
197192768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko            $RegisteredSONAMEs{$LibVersion}{$SONAME} = $Path;
197202768170ccc4d3f55596a3ead8a8fee2ee67779bbAndrey Ponomarenko        }
197219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
1972257a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko    if(my $Short = parse_libname($Name, "name+ext", $OStarget)) {
1972357a405d1e779b8b4abd15b01a111b74960b0b265Andrey Ponomarenko        $RegisteredObjects_Short{$LibVersion}{$Short} = $Path;
197249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197259927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
197269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
197279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSONAME($)
197289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
197299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $Path = $_[0];
197309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return if(not $Path);
197319927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"getSONAME"}{$Path}) {
197329927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"getSONAME"}{$Path};
197339927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197349927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $ObjdumpCmd = get_CmdPath("objdump");
197359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $ObjdumpCmd) {
197369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        exitStatus("Not_Found", "can't find \"objdump\"");
197379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197389927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my $SonameCmd = "$ObjdumpCmd -x $Path 2>$TMP_DIR/null";
197399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if($OSgroup eq "windows") {
197409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | find \"SONAME\"";
197419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    else {
197439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $SonameCmd .= " | grep SONAME";
197449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197459927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(my $SonameInfo = `$SonameCmd`) {
197469927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($SonameInfo=~/SONAME\s+([^\s]+)/) {
197479927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            return ($Cache{"getSONAME"}{$Path} = $1);
197489927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
197499927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
197509927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"getSONAME"}{$Path}="");
19751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getSOPaths_Dest($$)
19754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Dest, $LibVersion) = @_;
197568f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(skipLib($Dest, $LibVersion)) {
19757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-f $Dest)
19760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not parse_libname($Dest, "name", $OStarget)) {
19762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "incorrect format of library (should be *.$LIB_EXT): \'$Dest\'");
19763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
197649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject($Dest, $LibVersion);
197659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        registerObject_Dir(get_dirname($Dest), $LibVersion);
19766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ($Dest);
19767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(-d $Dest)
19769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Dest=~s/[\/\\]+\Z//g;
1977162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Libs = ();
19772570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(grep { $Dest eq $_ } @{$SystemPaths{"lib"}})
19773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # you have specified /usr/lib as the search directory (<libs>) in the XML descriptor
19774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and the real name of the library by -l option (bz2, stdc++, Xaw, ...)
19775570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (cmd_find($Dest,"","*".esc($TargetLibraryName)."*.$LIB_EXT*",2))
19776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # all files and symlinks that match the name of a library
19777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(get_filename($Path)=~/\A(|lib)\Q$TargetLibraryName\E[\d\-]*\.$LIB_EXT[\d\.]*\Z/i)
19778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
197799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    registerObject($Path, $LibVersion);
1978074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $Libs{realpath($Path)}=1;
19781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19782ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19783ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19784ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19785ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # search for all files and symlinks
19786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Path (find_libs($Dest,"",""))
19787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
19788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                next if(ignore_path($Path));
197898f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                next if(skipLib($Path, $LibVersion));
197909927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                registerObject($Path, $LibVersion);
1979174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $Libs{realpath($Path)}=1;
19792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OSgroup eq "macos")
19794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # shared libraries on MacOS X may have no extension
19795570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                foreach my $Path (cmd_find($Dest,"f"))
19796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
19797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next if(ignore_path($Path));
197988f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                    next if(skipLib($Path, $LibVersion));
19799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if(get_filename($Path)!~/\./
19800850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    and cmd_file($Path)=~/(shared|dynamic)\s+library/i)
19801850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                    {
198029927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        registerObject($Path, $LibVersion);
1980374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $Libs{realpath($Path)}=1;
19804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
19805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
19806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
1980862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return keys(%Libs);
19809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
19811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return ();
19812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
198151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub isCyclical($$)
198161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
198171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my ($Stack, $Value) = @_;
198181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    return (grep {$_ eq $Value} @{$Stack});
19819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detectWordSize()
19822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $GCC_PATH);
19824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"detectWordSize"}) {
19825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"detectWordSize"};
19826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
19828a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Defines = `$GCC_PATH -E -dD \"$TMP_DIR/empty.h\"`;
19829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
19830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $WSize = 0;
19831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Defines=~/ __SIZEOF_POINTER__\s+(\d+)/)
198321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 4
19833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $WSize = $1;
19834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Defines=~/ __PTRDIFF_TYPE__\s+(\w+)/)
198361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # GCC 3
19837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $PTRDIFF = $1;
19838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($PTRDIFF=~/long/) {
1983962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WSize = "8";
19840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
1984262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WSize = "4";
19843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1984501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $WSize) {
19846ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't check WORD size");
19847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"detectWordSize"} = $WSize);
19849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19851f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenkosub getWordSize($) {
19852f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    return $WORD_SIZE{$_[0]};
19853f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko}
19854f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
19855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub majorVersion($)
19856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $V = $_[0];
19858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if(not $V);
19859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VParts = split(/\./, $V);
19860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $VParts[0];
19861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub cmpVersions($$)
198641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{ # compare two versions in dotted-numeric format
19865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($V1, $V2) = @_;
19866ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0 if($V1 eq $V2);
19867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V1Parts = split(/\./, $V1);
19868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @V2Parts = split(/\./, $V2);
19869570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    for (my $i = 0; $i <= $#V1Parts && $i <= $#V2Parts; $i++)
19870570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
19871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return -1 if(int($V1Parts[$i]) < int($V2Parts[$i]));
19872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 1 if(int($V1Parts[$i]) > int($V2Parts[$i]));
19873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return -1 if($#V1Parts < $#V2Parts);
19875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1 if($#V1Parts > $#V2Parts);
19876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
19877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
19878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
19879ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_ABI_Dump($$)
19880ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
19881ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
19882ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return if(not $LibVersion or not -e $Path);
19883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $FilePath = "";
198849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(isDump_U($Path))
19885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi
19886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = $Path;
19887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
19889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # input *.abi.tar.gz
19890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $FilePath = unpackDump($Path);
198919927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(not isDump_U($FilePath)) {
198929927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
198939927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
19894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19895850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1989601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ABI = {};
19897850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
1989801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $Line = readLineNum($FilePath, 0);
1989901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($Line=~/xml/)
1990001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # XML format
1990101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        loadModule("XmlDump");
1990201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = readXmlDump($FilePath);
19903ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1990401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    else
1990501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # Perl Data::Dumper format (default)
1990601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        open(DUMP, $FilePath);
1990701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        local $/ = undef;
1990801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $Content = <DUMP>;
1990901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        close(DUMP);
1991001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
1991101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(get_dirname($FilePath) eq $TMP_DIR."/unpack")
1991201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # remove temp file
1991301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            unlink($FilePath);
1991401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1991501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Content!~/};\s*\Z/) {
1991601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Invalid_Dump", "specified ABI dump \'$Path\' is not valid, try to recreate it");
1991701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
1991801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI = eval($Content);
1991901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $ABI) {
1992001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
1992101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
19922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # new dumps (>=1.22) have a personal versioning
19924570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my $DVersion = $ABI->{"ABI_DUMP_VERSION"};
1992501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my $ToolVersion = $ABI->{"ABI_COMPLIANCE_CHECKER_VERSION"};
19926570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(not $DVersion)
19927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # old dumps (<=1.21.6) have been marked by the tool version
19928570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $DVersion = $ToolVersion;
19929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19930570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $UsedDump{$LibVersion}{"V"} = $DVersion;
19931fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19932fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($ABI->{"ABI_DUMP_VERSION"})
19933fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
19934570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(cmpVersions($DVersion, $ABI_DUMP_VERSION)>0)
19935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19936570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $ABI_DUMP_VERSION)");
19937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19938fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19939fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    else
19940fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19941fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(cmpVersions($DVersion, $TOOL_VERSION)>0)
19942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # Don't know how to parse future dump formats
19943570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (newer than $TOOL_VERSION)");
19944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19945fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19946fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(majorVersion($DVersion)<2)
19947fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
19948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UseOldDumps)
19949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19950570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(cmpVersions($DVersion, $OLDEST_SUPPORTED_VERSION)<0) {
19951570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                exitStatus("Dump_Version", "incompatible version \'$DVersion\' of specified ABI dump (older than $OLDEST_SUPPORTED_VERSION)");
19952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
19955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
19956fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            my $Msg = "incompatible version \'$DVersion\' of specified ABI dump (allowed only 2.0<=V<=$ABI_DUMP_VERSION)";
19957570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(cmpVersions($DVersion, $OLDEST_SUPPORTED_VERSION)>=0) {
19958fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $Msg .= "\nUse -old-dumps option to use old-version dumps ($OLDEST_SUPPORTED_VERSION<=V<2.0)";
19959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
19960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Dump_Version", $Msg);
19961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
19962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
19963fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19964fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"ABI_DUMPER_VERSION"})
19965fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # DWARF ABI Dump
19966fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"P"} = 1;
19967fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UseConv_Real{$LibVersion}{"R"} = 0; # not implemented yet
19968fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19969fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $UsedDump{$LibVersion}{"DWARF"} = 1;
19970fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
19971fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $TargetComponent = "module";
19972fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
19973fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
199745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.11"))
199755c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # old ABI dumps
199765c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
199771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
1997801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    elsif($ABI->{"BinOnly"})
199791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # ABI dump created with --binary option
199801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $UsedDump{$LibVersion}{"BinOnly"} = 1;
199811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
199825c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
199835c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # default
199845c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $UsedDump{$LibVersion}{"SrcBin"} = 1;
199855c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
19986fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
1998701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(defined $ABI->{"Mode"}
1998801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    and $ABI->{"Mode"} eq "Extended")
19989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
19990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ExtendedCheck = 1;
19991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
1999274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ABI->{"Extra"}) {
1999374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ExtraDump = 1;
1999474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
1999574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
1999601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(my $Lang = $ABI->{"Language"})
19997ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
19998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UsedDump{$LibVersion}{"L"} = $Lang;
19999ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        setLanguage($LibVersion, $Lang);
20000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2000162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2000201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $TypeInfo{$LibVersion} = $ABI->{"TypeInfo"};
2000362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2000462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
20005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2000601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $TInfo = $ABI->{"TypeInfo"};
2000762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TInfo)
2000862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for older ABI dumps
2000901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TInfo = $ABI->{"TypeDescr"};
2001062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2001162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Tid_TDid = ();
2001262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $TDid (keys(%{$TInfo}))
2001362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2001462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TInfo->{$TDid}}))
2001562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2001662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $Tid if($Tid>$MAX_ID);
2001762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $MAX_ID = $TDid if($TDid and $TDid>$MAX_ID);
20018177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                $Tid_TDid{$Tid}{$TDid} = 1;
2001962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2002062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2002162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %NewID = ();
2002262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%Tid_TDid))
2002362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2002462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my @TDids = keys(%{$Tid_TDid{$Tid}});
2002562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($#TDids>=1)
2002662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2002762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                foreach my $TDid (@TDids)
2002862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
2002962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($TDid) {
2003062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
2003162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
2003262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    else
2003362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    {
20034177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        my $ID = ++$MAX_ID;
20035177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20036177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $NewID{$TDid}{$Tid} = $ID;
20037177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        %{$TypeInfo{$LibVersion}{$ID}} = %{$TInfo->{$TDid}{$Tid}};
20038177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                        $TypeInfo{$LibVersion}{$ID}{"Tid"} = $ID;
2003962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    }
2004062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2004162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2004262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else
2004362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2004462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $TDid = $TDids[0];
2004562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                %{$TypeInfo{$LibVersion}{$Tid}} = %{$TInfo->{$TDid}{$Tid}};
2004662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2004762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2004862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
2004962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2005062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            my %Info = %{$TypeInfo{$LibVersion}{$Tid}};
2005162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(defined $Info{"BaseType"})
2005262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2005362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $Bid = $Info{"BaseType"}{"Tid"};
2005462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BDid = $Info{"BaseType"}{"TDid"};
2005562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $BDid="" if(not defined $BDid);
20056fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                delete($TypeInfo{$LibVersion}{$Tid}{"BaseType"}{"TDid"});
2005762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(defined $NewID{$BDid} and my $ID = $NewID{$BDid}{$Bid}) {
20058fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$Tid}{"BaseType"} = $ID;
2005962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2006062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2006162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$Tid}{"TDid"});
2006262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2006401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Machine_DumpInfo($ABI, $LibVersion);
2006501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymbolInfo{$LibVersion} = $ABI->{"SymbolInfo"};
20066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SymbolInfo{$LibVersion})
20067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2006801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SymbolInfo{$LibVersion} = $ABI->{"FuncDescr"};
20069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{$LibVersion}}))
20071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validation of old-version dumps
20072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck) {
20073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Invalid_Dump", "the input dump d$LibVersion is invalid");
20074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2007662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(checkDump($LibVersion, "2.15")) {
2007701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $DepLibrary_Symbol{$LibVersion} = $ABI->{"DepSymbols"};
20078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2007962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    else
2008062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2008101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        my $DepSymbols = $ABI->{"DepSymbols"};
2008262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols) {
2008301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $DepSymbols = $ABI->{"DepInterfaces"};
2008462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2008562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $DepSymbols)
2008662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # Cannot reconstruct DepSymbols. This may result in false
2008762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # positives if the old dump is for library 2. Not a problem if
2008862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko          # old dumps are only from old libraries.
2008962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbols = {};
2009062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2009162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepSymbols})) {
2009262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = 1;
2009362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
20094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2009501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SymVer{$LibVersion} = $ABI->{"SymbolVersion"};
2009601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Descriptor{$LibVersion}{"Version"} = $ABI->{"LibraryVersion"};
2009701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipTypes{$LibVersion} = $ABI->{"SkipTypes"};
20098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipTypes{$LibVersion})
20099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2010001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipTypes{$LibVersion} = $ABI->{"OpaqueTypes"};
20101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2010201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipSymbols{$LibVersion} = $ABI->{"SkipSymbols"};
20103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
20104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2010501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"SkipInterfaces"};
20106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $SkipSymbols{$LibVersion})
20108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2010901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipSymbols{$LibVersion} = $ABI->{"InternalInterfaces"};
20110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2011101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $SkipNameSpaces{$LibVersion} = $ABI->{"SkipNameSpaces"};
2011201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $TargetHeaders{$LibVersion} = $ABI->{"TargetHeaders"};
2011301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Path (keys(%{$ABI->{"SkipHeaders"}}))
20114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2011501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeadersList{$LibVersion}{$Path} = $ABI->{"SkipHeaders"}{$Path};
20116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($CPath, $Type) = classifyPath($Path);
2011701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $SkipHeaders{$LibVersion}{$Type}{$CPath} = $ABI->{"SkipHeaders"}{$Path};
20118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20119fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    read_Source_DumpInfo($ABI, $LibVersion);
2012001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    read_Libs_DumpInfo($ABI, $LibVersion);
201215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(not checkDump($LibVersion, "2.10.1")
201225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    or not $TargetHeaders{$LibVersion})
20123850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    { # support for old ABI dumps: added target headers
20124850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
201253e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20127fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
201283e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20129fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2013101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $Constants{$LibVersion} = $ABI->{"Constants"};
20132fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(defined $ABI->{"GccConstants"})
20133fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # 3.0
20134fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Name (keys(%{$ABI->{"GccConstants"}})) {
20135fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $Constants{$LibVersion}{$Name}{"Value"} = $ABI->{"GccConstants"}{$Name};
20136fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20137fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20138fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2013901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    $NestedNameSpaces{$LibVersion} = $ABI->{"NameSpaces"};
20140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $NestedNameSpaces{$LibVersion})
20141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
20142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # Cannot reconstruct NameSpaces. This may affect design
20143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # of the compatibility report.
20144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $NestedNameSpaces{$LibVersion} = {};
20145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # target system type
20147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # needed to adopt HTML report
20148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $DumpSystem)
20149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # to use in createSymbolsList(...)
2015001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $OStarget = $ABI->{"Target"};
20151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # recreate environment
20153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$Library_Symbol{$LibVersion}}))
20154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
2015562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$Library_Symbol{$LibVersion}{$Lib_Name}}))
20156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2015762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $Symbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2015862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol}<=-1)
20159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # data marked as -size in the dump
20160fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                $GlobalDataObject{$LibVersion}{$Symbol} = -$Library_Symbol{$LibVersion}{$Lib_Name}{$Symbol};
20161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
201629927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            if($COMMON_LANGUAGE{$LibVersion} ne "C++")
201639927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
201649927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                if(index($Symbol, "_Z")==0 or index($Symbol, "?")==0) {
201659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    setLanguage($LibVersion, "C++");
201669927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                }
20167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2017062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $Lib_Name (keys(%{$DepLibrary_Symbol{$LibVersion}}))
2017162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2017262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $Symbol (keys(%{$DepLibrary_Symbol{$LibVersion}{$Lib_Name}})) {
2017362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $DepSymbol_Library{$LibVersion}{$Symbol} = $Lib_Name;
2017462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2017562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2017662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @VFunc = ();
201781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20180f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(my $MnglName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
2018162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2018262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $Symbol_Library{$LibVersion}{$MnglName}
2018362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            and not $DepSymbol_Library{$LibVersion}{$MnglName}) {
2018462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                push(@VFunc, $MnglName);
2018562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
20186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(@VFunc, $LibVersion);
20189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2019062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
2019162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
20192fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not checkDump($LibVersion, "3.0"))
20193fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # support for old ABI dumps
20194fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20195fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
20196fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseType = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
20197fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            {
20198fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                if(ref($BaseType) eq "HASH") {
20199fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"BaseType"} = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"}{"Tid"};
20200fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                }
20201fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            }
20202fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20203fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20204fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20205177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    if(not checkDump($LibVersion, "3.2"))
20206177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    { # support for old ABI dumps
20207177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20208177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20209177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(defined $TypeInfo{$LibVersion}{$TypeId}{"VTable"})
20210177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20211177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                foreach my $Offset (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"VTable"}})) {
20212177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset} = simplifyVTable($TypeInfo{$LibVersion}{$TypeId}{"VTable"}{$Offset});
20213177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                }
20214177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20215177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20216177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20217177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # repair target headers list
20218177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        delete($TargetHeaders{$LibVersion});
20219177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach (keys(%{$Registered_Headers{$LibVersion}})) {
202203e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
202213e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        }
202223e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko        foreach (keys(%{$Registered_Sources{$LibVersion}})) {
202233e69aa34938c9daf12718f2fe825c43a890edaa1Andrey Ponomarenko            $TargetHeaders{$LibVersion}{get_filename($_)} = 1;
20224177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20225177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
20226177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        # non-target constants from anon enums
20227177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        foreach my $Name (keys(%{$Constants{$LibVersion}}))
20228177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        {
20229177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            if(not $ExtraDump
20230177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            and not is_target_header($Constants{$LibVersion}{$Name}{"Header"}, $LibVersion))
20231177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            {
20232177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko                delete($Constants{$LibVersion}{$Name});
20233177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko            }
20234177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko        }
20235177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko    }
20236177a66ff01fead52b6f6e28ef2fc0b08b73ba27bAndrey Ponomarenko
2023774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if(not checkDump($LibVersion, "2.20"))
2023874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    { # support for old ABI dumps
2023974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2024074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2024174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2024274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2024374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum|Typedef/)
2024474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            { # repair complex types first
2024574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                next;
2024674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2024774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
20248fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BaseId = $TypeInfo{$LibVersion}{$TypeId}{"BaseType"})
2024974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            {
2025074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                my $BType = lc($TypeInfo{$LibVersion}{$BaseId}{"Type"});
2025174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($BType=~/Struct|Union|Enum/i)
2025274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2025374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $BName = $TypeInfo{$LibVersion}{$BaseId}{"Name"};
2025474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    $TypeInfo{$LibVersion}{$TypeId}{"Name"}=~s/\A\Q$BName\E\b/$BType $BName/g;
2025574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                }
2025674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2025774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2025874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
2025974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        {
2026074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TType = $TypeInfo{$LibVersion}{$TypeId}{"Type"};
2026174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $TName = $TypeInfo{$LibVersion}{$TypeId}{"Name"};
2026274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if($TType=~/Struct|Union|Enum/) {
2026374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Name"} = lc($TType)." ".$TName;
2026474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            }
2026574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2026674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2026774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2026862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    foreach my $TypeId (sort {int($a)<=>int($b)} keys(%{$TypeInfo{$LibVersion}}))
20269f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    { # order is important
2027062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"})
2027162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # support for old ABI dumps < 2.0 (ACC 1.22)
2027262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $BId (keys(%{$TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}}))
2027362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2027462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(my $Access = $TypeInfo{$LibVersion}{$TypeId}{"BaseClass"}{$BId})
20275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
2027662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    if($Access ne "public") {
2027762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId}{"access"} = $Access;
20278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
20279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2028062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $TypeInfo{$LibVersion}{$TypeId}{"Base"}{$BId} = {};
2028162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2028262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseClass"});
2028362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
202849927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $TypeInfo{$LibVersion}{$TypeId}{"Header"})
202859927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
202869927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = path_format($Header, $OSgroup);
202879927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20288fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $TypeInfo{$LibVersion}{$TypeId}{"Source"})
20289fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20290fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Header"} = $Source;
20291fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
2029201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not defined $TypeInfo{$LibVersion}{$TypeId}{"Tid"}) {
2029301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            $TypeInfo{$LibVersion}{$TypeId}{"Tid"} = $TypeId;
2029401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2029562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %TInfo = %{$TypeInfo{$LibVersion}{$TypeId}};
2029662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(defined $TInfo{"Base"})
2029762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2029862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach (keys(%{$TInfo{"Base"}})) {
2029962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                $Class_SubClasses{$LibVersion}{$_}{$TypeId}=1;
2030062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2030162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2030201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($TInfo{"Type"} eq "MethodPtr")
2030301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        {
2030401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if(defined $TInfo{"Param"})
2030501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # support for old ABI dumps <= 1.17
2030601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                if(not defined $TInfo{"Param"}{"0"})
2030701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                {
2030801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    my $Max = keys(%{$TInfo{"Param"}});
2030901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    foreach my $Pos (1 .. $Max) {
2031001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $TInfo{"Param"}{$Pos-1} = $TInfo{"Param"}{$Pos};
2031101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2031201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    delete($TInfo{"Param"}{$Max});
2031301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    %{$TypeInfo{$LibVersion}{$TypeId}} = %TInfo;
2031401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2031501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2031601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20317fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"BaseType"} eq $TypeId)
20318fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # fix ABI dump
20319fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($TypeInfo{$LibVersion}{$TypeId}{"BaseType"});
20320fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20321fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if($TInfo{"Type"} eq "Typedef" and not $TInfo{"Artificial"})
2032262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
20323fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            if(my $BTid = $TInfo{"BaseType"})
2032462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            {
2032562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                my $BName = $TypeInfo{$LibVersion}{$BTid}{"Name"};
2032662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $BName)
2032762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # broken type
2032862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2032962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2033062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TInfo{"Name"} eq $BName)
2033162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # typedef to "class Class"
203328f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                  # should not be registered in TName_Tid
2033362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
2033462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
2033562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}}) {
2033662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $Typedef_BaseName{$LibVersion}{$TInfo{"Name"}} = $BName;
2033762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                }
20338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2033962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2034062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not $TName_Tid{$LibVersion}{$TInfo{"Name"}})
2034162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        { # classes: class (id1), typedef (artificial, id2 > id1)
20342fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $TName_Tid{$LibVersion}{formatName($TInfo{"Name"}, "T")} = $TypeId;
2034362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2034462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2034562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko
2034662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump($LibVersion, "2.15"))
2034762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    { # support for old ABI dumps
2034862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my %Dups = ();
2034962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
2035062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2035162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(my $ClassId = $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
20352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2035362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if(not defined $TypeInfo{$LibVersion}{$ClassId})
2035462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # remove template decls
2035562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    delete($SymbolInfo{$LibVersion}{$InfoId});
2035662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    next;
20357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20359b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            my $MName = $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"};
20360b8d203dfe35b781f33c9281d1cdeacac73fc6f73Andrey Ponomarenko            if(not $MName and $SymbolInfo{$LibVersion}{$InfoId}{"Class"})
2036162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            { # templates
2036262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                delete($SymbolInfo{$LibVersion}{$InfoId});
20363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20367f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    foreach my $InfoId (keys(%{$SymbolInfo{$LibVersion}}))
20368f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    {
20369ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if(my $Class = $SymbolInfo{$LibVersion}{$InfoId}{"Class"}
20370ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Static"}
20371ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        and not $SymbolInfo{$LibVersion}{$InfoId}{"Data"})
20372ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        { # support for old ABI dumps (< 3.1)
20373ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            if(not defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"}
20374ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            or $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{0}{"name"} ne "this")
20375ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            { # add "this" first parameter
20376ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my $ThisTid = getTypeIdByName($TypeInfo{$LibVersion}{$Class}{"Name"}."*const", $LibVersion);
20377ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                my %PInfo = ("name"=>"this", "type"=>"$ThisTid");
20378ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20379ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                if(defined $SymbolInfo{$LibVersion}{$InfoId}{"Param"})
20380ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                {
20381ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    my @Pos = sort {int($a)<=>int($b)} keys(%{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}});
20382ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    foreach my $Pos (reverse(0 .. $#Pos)) {
20383ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                        %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos+1}} = %{$SymbolInfo{$LibVersion}{$InfoId}{"Param"}{$Pos}};
20384ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                    }
20385ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                }
20386ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko                $SymbolInfo{$LibVersion}{$InfoId}{"Param"}{"0"} = \%PInfo;
20387ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            }
20388ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
20389ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko
20390f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if(not $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"})
20391f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        { # ABI dumps have no mangled names for C-functions
20392f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"MnglName"} = $SymbolInfo{$LibVersion}{$InfoId}{"ShortName"};
20393f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
203949927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if(my $Header = $SymbolInfo{$LibVersion}{$InfoId}{"Header"})
203959927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        { # support for old ABI dumps
203969927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = path_format($Header, $OSgroup);
203979927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        }
20398fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        elsif(my $Source = $SymbolInfo{$LibVersion}{$InfoId}{"Source"})
20399fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        { # DWARF ABI Dumps
20400fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SymbolInfo{$LibVersion}{$InfoId}{"Header"} = $Source;
20401fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
20402f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    }
20403f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko
20404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Descriptor{$LibVersion}{"Dump"} = 1;
20405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Machine_DumpInfo($$)
20408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2040901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
2041001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"Arch"}) {
2041101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $CPU_ARCH{$LibVersion} = $ABI->{"Arch"};
20412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2041301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"WordSize"}) {
2041401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"WordSize"};
20415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps
2041801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{$LibVersion} = $ABI->{"SizeOfPointer"};
20419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $WORD_SIZE{$LibVersion})
20421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old dumps (<1.23)
20422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $Tid = getTypeIdByName("char*", $LibVersion))
20423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # size of char*
2042462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $WORD_SIZE{$LibVersion} = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $PSize = 0;
2042962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            foreach my $Tid (keys(%{$TypeInfo{$LibVersion}}))
20430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
2043162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($TypeInfo{$LibVersion}{$Tid}{"Type"} eq "Pointer")
2043262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                { # any "pointer"-type
2043362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                    $PSize = $TypeInfo{$LibVersion}{$Tid}{"Size"};
20434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    last;
20435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20437ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($PSize)
20438ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # a pointer type size
20439ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $WORD_SIZE{$LibVersion} = $PSize;
20440ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20441ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20442ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("WARNING", "cannot identify a WORD size in the ABI dump (too old format)");
20443ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20444ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20445ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2044601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if($ABI->{"GccVersion"}) {
2044701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $GCC_VERSION{$LibVersion} = $ABI->{"GccVersion"};
20448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub read_Libs_DumpInfo($$)
20452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2045301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
204549927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    $Library_Symbol{$LibVersion} = $ABI->{"Symbols"};
204559927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(not $Library_Symbol{$LibVersion})
204569927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    { # support for old dumps
204579927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $Library_Symbol{$LibVersion} = $ABI->{"Interfaces"};
204589927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
20459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%{$Library_Symbol{$LibVersion}})
20460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Libs"} = "OK";
20462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20465fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenkosub read_Source_DumpInfo($$)
20466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2046701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my ($ABI, $LibVersion) = @_;
20468fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
2046901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(keys(%{$ABI->{"Headers"}})
20470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $DumpAPI) {
20471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Descriptor{$LibVersion}{"Headers"} = "OK";
20472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2047301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    foreach my $Identity (sort {$ABI->{"Headers"}{$a}<=>$ABI->{"Headers"}{$b}} keys(%{$ABI->{"Headers"}}))
20474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # headers info is stored in the old dumps in the different way
20475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($UseOldDumps
2047601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        and my $Name = $ABI->{"Headers"}{$Identity}{"Name"})
20477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # support for old dumps: headers info corrected in 1.22
20478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Identity = $Name;
20479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Identity"} = $Identity;
2048101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $Registered_Headers{$LibVersion}{$Identity}{"Pos"} = $ABI->{"Headers"}{$Identity};
20482ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20483fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
20484fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(keys(%{$ABI->{"Sources"}})
20485fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    and not $DumpAPI) {
20486fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{$LibVersion}{"Sources"} = "OK";
20487fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20488fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (sort {$ABI->{"Sources"}{$a}<=>$ABI->{"Sources"}{$b}} keys(%{$ABI->{"Sources"}}))
20489fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # headers info is stored in the old dumps in the different way
20490fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Identity"} = $Name;
20491fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Registered_Sources{$LibVersion}{$Name}{"Pos"} = $ABI->{"Headers"}{$Name};
20492fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
20493ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20494ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20495ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub find_libs($$$)
20496ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20497ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Path, $Type, $MaxDepth) = @_;
20498ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # FIXME: correct the search pattern
204998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    return cmd_find($Path, $Type, '\.'.$LIB_EXT.'[0-9.]*\Z', $MaxDepth, 1);
20500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createDescriptor($$)
20503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20504ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
20505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $LibVersion or not $Path
20506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not -e $Path) {
20507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "";
20508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-d $Path)
20510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # directory with headers files and shared objects
20511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return "
20512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <version>
20513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ".$TargetVersion{$LibVersion}."
20514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </version>
20515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <headers>
20517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </headers>
20519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            <libs>
20521ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Path
20522ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            </libs>";
20523ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20524ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # files
205269927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($Path=~/\.(xml|desc)\Z/i)
20527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20529ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(is_header($Path, 2, $LibVersion))
20531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # header file
20532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20540ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20542ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20543ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20544ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20545ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif(parse_libname($Path, "name", $OStarget))
20546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # shared object
20547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "
20548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <version>
20549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    ".$TargetVersion{$LibVersion}."
20550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </version>
20551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
20553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    none
20554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
20555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
20557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path
20558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>";
20559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20560ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
20561ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # standard XML-descriptor
20562ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return readFile($Path);
20563ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20564ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20565ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20566ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20567ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_lib_default_paths()
20568ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20569ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %LPaths = ();
20570ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "bsd")
20571ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20572a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20573a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        {
20574a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -r 2>\"$TMP_DIR/null\"`))
20575a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
2057674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                if($Line=~/\A[ \t]*\d+:\-l(.+) \=\> (.+)\Z/)
2057774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                {
2057874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    my $Name = "lib".$1;
2057974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name}) {
2058074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $2;
2058174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20582ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20583ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20584ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20585ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
20586ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20587ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20588ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20589ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
20590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20591ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LdConfig = get_CmdPath("ldconfig"))
20592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $OSgroup eq "linux")
20594ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # use host (x86) ldconfig with the target (arm) ld.so.conf
20595ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-e $SystemRoot."/etc/ld.so.conf") {
20596ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LdConfig .= " -f ".$SystemRoot."/etc/ld.so.conf";
20597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20598ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20599a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            foreach my $Line (split(/\n/, `$LdConfig -p 2>\"$TMP_DIR/null\"`))
20600a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            {
20601ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($Line=~/\A[ \t]*([^ \t]+) .* \=\> (.+)\Z/)
20602ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20603ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my ($Name, $Path) = ($1, $2);
20604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $Path=~s/[\/]{2,}/\//;
2060574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    if(not defined $LPaths{$Name})
2060674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    { # get first element from the list of available paths
2060774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2060874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6,x86-64) => /usr/lib/x86_64-linux-gnu/libstdc++.so.6
2060974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib/i386-linux-gnu/libstdc++.so.6
2061074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                      # libstdc++.so.6 (libc6) => /usr/lib32/libstdc++.so.6
2061174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2061274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                        $LPaths{$Name} = $Path;
2061374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                    }
20614ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20616ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2061782b005fef3fa735e5a8cdd82c112629b5757e1cbAndrey Ponomarenko        elsif($OSgroup eq "linux") {
20618ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "can't find ldconfig");
20619ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20620ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20621ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%LPaths;
20622ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20623ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20624ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_bin_default_paths()
20625ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $EnvPaths = $ENV{"PATH"};
20627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos") {
20628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $EnvPaths.=":".$ENV{"BETOOLS"};
20629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Sep = ($OSgroup eq "windows")?";":":|;";
20631570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (split(/$Sep/, $EnvPaths))
20632ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20633ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Path = path_format($Path, $OSgroup);
20634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if(not $Path);
20635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot
20636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and $Path=~/\A\Q$SystemRoot\E\//)
20637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # do NOT use binaries from target system
20638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
20639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20640570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U(\@DefaultBinPaths, $Path);
20641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_inc_default_paths()
20645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return () if(not $GCC_PATH);
20647570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    my %DPaths = ("Cpp"=>[],"Gcc"=>[],"Inc"=>[]);
20648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile("$TMP_DIR/empty.h", "");
20649a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    foreach my $Line (split(/\n/, `$GCC_PATH -v -x c++ -E \"$TMP_DIR/empty.h\" 2>&1`))
206501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # detecting GCC default include paths
20651570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        next if(index($Line, "/cc1plus ")!=-1);
20652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20653ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Line=~/\A[ \t]*((\/|\w+:\\).+)[ \t]*\Z/)
20654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2065574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            my $Path = realpath($1);
20656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $Path = path_format($Path, $OSgroup);
20657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(index($Path, "c++")!=-1
20658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            or index($Path, "/g++/")!=-1)
20659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20660570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Cpp"}, $Path);
20661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not defined $MAIN_CPP_DIR
20662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                or get_depth($MAIN_CPP_DIR)>get_depth($Path)) {
20663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $MAIN_CPP_DIR = $Path;
20664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20666570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            elsif(index($Path, "gcc")!=-1) {
20667570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Gcc"}, $Path);
20668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
20670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20671570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if($Path=~/local[\/\\]+include/)
20672570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                { # local paths
20673570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    next;
20674570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $Path!~/\A\Q$SystemRoot\E(\/|\Z)/)
20677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # The GCC include path for user headers is not a part of the system root
20678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # The reason: you are not specified the --cross-gcc option or selected a wrong compiler
20679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # or it is the internal cross-GCC path like arm-linux-gnueabi/include
20680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20682570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($DPaths{"Inc"}, $Path);
20683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    unlink("$TMP_DIR/empty.h");
20687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return %DPaths;
20688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub detect_default_paths($)
20691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($HSearch, $LSearch, $BSearch, $GSearch) = (1, 1, 1, 1);
20693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Search = $_[0];
20694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/inc/) {
20695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/lib/) {
20698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/bin/) {
20701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $BSearch = 0;
20702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Search!~/gcc/) {
20704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $GSearch = 0;
20705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20706570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"include"}})
20707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HSearch = 0;
20710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20711570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if(@{$SystemPaths{"lib"}})
20712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # <search_headers> section of the XML descriptor
20713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # do NOT search for systems headers
20714ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $LSearch = 0;
20715ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Type (keys(%{$OS_AddPath{$OSgroup}}))
20717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # additional search paths
20718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "include" and not $HSearch);
20719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "lib" and not $LSearch);
20720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        next if($Type eq "bin" and not $BSearch);
20721570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{$Type}, grep { -d $_ } @{$OS_AddPath{$OSgroup}{$Type}});
20722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup ne "windows")
20724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # unix-like
20725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Type ("include", "lib", "bin")
20726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # automatic detection of system "devel" directories
20727ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "include" and not $HSearch);
20728ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "lib" and not $LSearch);
20729ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next if($Type eq "bin" and not $BSearch);
20730ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($UsrDir, $RootDir) = ("/usr", "/");
20731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($SystemRoot and $Type ne "bin")
20732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 1. search for target headers and libraries
20733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko              # 2. use host commands: ldconfig, readelf, etc.
20734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                ($UsrDir, $RootDir) = ("$SystemRoot/usr", $SystemRoot);
20735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20736570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U($SystemPaths{$Type}, cmd_find($RootDir,"d","*$Type*",1));
20737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-d $RootDir."/".$Type)
20738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # if "/lib" is symbolic link
20739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($RootDir eq "/") {
20740570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, "/".$Type);
20741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                else {
20743570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $RootDir."/".$Type);
20744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20746570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(-d $UsrDir)
20747570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
20748570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{$Type}, cmd_find($UsrDir,"d","*$Type*",1));
20749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(-d $UsrDir."/".$Type)
20750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # if "/usr/lib" is symbolic link
20751570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    push_U($SystemPaths{$Type}, $UsrDir."/".$Type);
20752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_bin_default_paths();
20759570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"bin"}, @DefaultBinPaths);
20760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check environment variables
20762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OSgroup eq "beos")
20763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
207644b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko        foreach (my @Paths = @{$SystemPaths{"bin"}})
20765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
207664b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if($_ eq ".") {
207674b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                next;
207684b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            }
207694b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            # search for /boot/develop/abi/x86/gcc4/tools/gcc-4.4.4-haiku-101111/bin/
207704b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko            if(my @Dirs = sort cmd_find($_, "d", "bin")) {
207714b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko                push_U($SystemPaths{"bin"}, sort {get_depth($a)<=>get_depth($b)} @Dirs);
20772ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($HSearch)
20775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20776570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultIncPaths, grep { is_abs($_) } (
20777570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BEINCLUDES"})
20778570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20779ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($LSearch)
20781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20782570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, grep { is_abs($_) } (
20783570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"BELIBRARIES"}),
20784570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                split(/:|;/, $ENV{"LIBRARY_PATH"})
20785570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                ));
20786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LSearch)
20789ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # using linker to get system paths
20790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(my $LPaths = detect_lib_default_paths())
20791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # unix-like
20792570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my %Dirs = ();
20793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Name (keys(%{$LPaths}))
20794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($SystemRoot
20796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                and $LPaths->{$Name}!~/\A\Q$SystemRoot\E\//)
20797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                { # wrong ldconfig configuration
20798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                  # check your <sysroot>/etc/ld.so.conf
20799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    next;
20800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DyLib_DefaultPath{$Name} = $LPaths->{$Name};
20802570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Dir = get_dirname($LPaths->{$Name})) {
20803570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    $Dirs{$Dir} = 1;
20804570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
20805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20806570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@DefaultLibPaths, sort {get_depth($a)<=>get_depth($b)} sort keys(%Dirs));
20807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20808570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        push_U($SystemPaths{"lib"}, @DefaultLibPaths);
20809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($BSearch)
20811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc)
20813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # --cross-gcc=arm-linux-gcc
20814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(-e $CrossGcc)
20815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # absolute or relative path
20816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = get_abs_path($CrossGcc);
20817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20818ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            elsif($CrossGcc!~/\// and get_CmdPath($CrossGcc))
20819ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # command name
20820ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = $CrossGcc;
20821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access \'$CrossGcc\'");
20824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($GCC_PATH=~/\s/) {
20826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $GCC_PATH = "\"".$GCC_PATH."\"";
20827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20828ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20829ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($GSearch)
20831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # GCC path and default include dirs
20832570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if(not $CrossGcc)
20833570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        { # try default gcc
20834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $GCC_PATH = get_CmdPath("gcc");
20835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2083601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $GCC_PATH)
2083701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        { # try to find gcc-X.Y
20838570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            foreach my $Path (@{$SystemPaths{"bin"}})
2083901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            {
208408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                if(my @GCCs = cmd_find($Path, "", '/gcc-[0-9.]*\Z', 1, 1))
2084101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                { # select the latest version
2084201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    @GCCs = sort {$b cmp $a} @GCCs;
2084301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    if(check_gcc($GCCs[0], "3"))
2084401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    {
2084501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        $GCC_PATH = $GCCs[0];
2084601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                        last;
2084701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                    }
2084801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                }
2084901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2085001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
20851ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $GCC_PATH) {
20852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Not_Found", "can't find GCC>=3.0 in PATH");
20853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20854f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
20855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckObjectsOnly_Opt)
20856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
20857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $GCC_Ver = get_dumpversion($GCC_PATH))
20858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
20859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $GccTarget = get_dumpmachine($GCC_PATH);
20860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                printMsg("INFO", "Using GCC $GCC_Ver ($GccTarget)");
20861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if($GccTarget=~/symbian/)
20862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
20863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $OStarget = "symbian";
20864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $LIB_EXT = $OS_LibExt{$LIB_TYPE}{$OStarget};
20865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
20866f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
20867f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                # check GCC version
20868f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                if($GCC_Ver=~/\A4\.8(|\.0|\.1)\Z/)
20869f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                { # bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57850
20870f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey 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.");
20871f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                    $EMERGENCY_MODE_48 = 1;
20872f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko                }
20873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
20875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Error", "something is going wrong with the GCC compiler");
20876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20878570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        if($HSearch)
20879570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
20880570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not $NoStdInc)
20881570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # do NOT search in GCC standard paths
20882570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                my %DPaths = detect_inc_default_paths();
20883570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                @DefaultCppPaths = @{$DPaths{"Cpp"}};
20884570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                @DefaultGccPaths = @{$DPaths{"Gcc"}};
20885570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                @DefaultIncPaths = @{$DPaths{"Inc"}};
20886570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"include"}, @DefaultIncPaths);
20887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
20888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($HSearch)
20891570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # users include paths
20892dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        my $IncPath = "/usr/include";
20893dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($SystemRoot) {
20894dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            $IncPath = $SystemRoot.$IncPath;
20895dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
20896dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if(-d $IncPath) {
20897570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            push_U(\@UsersIncPath, $IncPath);
20898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2090074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2090174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraInfo)
2090274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    {
2090374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-libs", join("\n", @DefaultLibPaths));
2090474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        writeFile($ExtraInfo."/default-includes", join("\n", (@DefaultCppPaths, @DefaultGccPaths, @DefaultIncPaths)));
2090574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
20906ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20907ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20908ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getLIB_EXT($)
20909ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20910ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20911ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_LibExt{$LIB_TYPE}{$Target}) {
20912ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20913ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20914ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_LibExt{$LIB_TYPE}{"default"};
20915ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20916ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20917ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub getAR_EXT($)
20918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20919ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Target = $_[0];
20920ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $Ext = $OS_Archive{$Target}) {
20921ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Ext;
20922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20923ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $OS_Archive{"default"};
20924ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20925ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20926ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpversion($)
20927ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20929ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpversion"}{$Cmd}) {
20931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpversion"}{$Cmd};
20932ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20933a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $V = `$Cmd -dumpversion 2>\"$TMP_DIR/null\"`;
20934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($V);
20935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpversion"}{$Cmd} = $V);
20936ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_dumpmachine($)
20939ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Cache{"get_dumpmachine"}{$Cmd}) {
20943ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $Cache{"get_dumpmachine"}{$Cmd};
20944ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20945a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    my $Machine = `$Cmd -dumpmachine 2>\"$TMP_DIR/null\"`;
20946ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    chomp($Machine);
20947ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_dumpmachine"}{$Cmd} = $Machine);
20948ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20949ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20950570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub checkCmd($)
20951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Cmd = $_[0];
20953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Cmd);
20954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @Options = (
20955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "--version",
20956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "-help"
20957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
20958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Opt (@Options)
20959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20960a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        my $Info = `$Cmd $Opt 2>\"$TMP_DIR/null\"`;
20961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Info) {
20962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return 1;
20963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
20964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
20966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2096862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenkosub check_gcc($$)
20969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
2097062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    my ($Cmd, $ReqVer) = @_;
2097162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return 0 if(not $Cmd or not $ReqVer);
2097262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(defined $Cache{"check_gcc"}{$Cmd}{$ReqVer}) {
2097362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        return $Cache{"check_gcc"}{$Cmd}{$ReqVer};
20974ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2097562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(my $GccVer = get_dumpversion($Cmd))
2097662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2097762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $GccVer=~s/(-|_)[a-z_]+.*\Z//; # remove suffix (like "-haiku-100818")
2097862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(cmpVersions($GccVer, $ReqVer)>=0) {
2097962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = $Cmd);
2098062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2098162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
2098262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    return ($Cache{"check_gcc"}{$Cmd}{$ReqVer} = "");
20983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub get_depth($)
20986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(defined $Cache{"get_depth"}{$_[0]}) {
209889927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"get_depth"}{$_[0]};
20989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
20990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return ($Cache{"get_depth"}{$_[0]} = ($_[0]=~tr![\/\\]|\:\:!!));
20991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
20992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
20993570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerGccHeaders()
20994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
20995570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerGccHeaders"}); # this function should be called once
20996570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
20997570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $Path (@DefaultGccPaths)
20998ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
20999570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($Path,"f");
21000570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
21001570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $HPath (@Headers)
21002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21003570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($HPath);
21004570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultGccHeader{$FileName})
21005570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
21006570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $DefaultGccHeader{$FileName} = $HPath;
21007570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21010570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerGccHeaders"} = 1;
21011570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko}
21012570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21013570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenkosub registerCppHeaders()
21014570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko{
21015570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    return if($Cache{"registerCppHeaders"}); # this function should be called once
21016570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko
21017570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    foreach my $CppDir (@DefaultCppPaths)
21018ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21019570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Headers = cmd_find($CppDir,"f");
21020570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        @Headers = sort {get_depth($a)<=>get_depth($b)} @Headers;
21021570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $Path (@Headers)
21022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21023570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            my $FileName = get_filename($Path);
21024570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(not defined $DefaultCppHeader{$FileName})
21025570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            { # skip duplicated
21026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $DefaultCppHeader{$FileName} = $Path;
21027ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21030570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    $Cache{"registerCppHeaders"} = 1;
21031ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname($$$)
21034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
210359927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return "" if(not $_[0]);
210369927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    if(defined $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]}) {
210379927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]};
21038dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
210399927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return ($Cache{"parse_libname"}{$_[2]}{$_[1]}{$_[0]} = parse_libname_I(@_));
210409927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
210419927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
210429927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub parse_libname_I($$$)
210439927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
210449927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    my ($Name, $Type, $Target) = @_;
21045fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Target eq "symbian") {
21047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_symbian($Name, $Type);
21048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif($Target eq "windows") {
21050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return parse_libname_windows($Name, $Type);
21051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21052fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21053fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    # unix
21054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT($Target);
21055a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if($Name=~/((((lib|).+?)([\-\_][\d\-\.\_]+.*?|))\.$Ext)(\.(.+)|)\Z/)
21056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libSDL-1.2.so.0.7.1
21057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # libwbxml2.so.0.0.18
21058a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko      # libopcodes-2.21.53-system.20110810.so
21059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2
21061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL-1.2.so
21066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2.so
21067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21071a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            if(defined $7
21072a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko            and $7 ne "")
21073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # 0.7.1
21074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $7;
21075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else
21077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            { # libc-2.5.so (=>2.5 version)
21078ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $MV = $5;
21079ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $MV=~s/\A[\-\_]+//g;
21080ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                return $MV;
21081ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21082ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21083ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21084ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libSDL
21085ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # libwbxml2
21086ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21087ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21088ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # SDL
21090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # wbxml
21091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_symbian($$)
21098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("symbian");
21101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/(((.+?)(\{.+\}|))\.$Ext)\Z/)
21102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # libpthread{00010001}.dso
21103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}
21105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21108ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread{00010001}.dso
21109ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # 00010001
21113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $V = $4;
21114ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $V=~s/\{(.+)\}/$1/;
21115ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $V;
21116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # libpthread
21119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $3;
21120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21121ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21122ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # pthread
21123ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($3);
21124ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21129ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub parse_libname_windows($$)
21130ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Name, $Type) = @_;
21132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Ext = getLIB_EXT("windows");
21133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Name=~/((.+?)\.$Ext)\Z/)
21134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # netapi32.dll
21135ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "name")
21136ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "name+ext")
21140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32.dll
21141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $1;
21142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "version")
21144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # DLL version embedded
21145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # at binary-level
21146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return "";
21147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "short")
21149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi32
21150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return $2;
21151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($Type eq "shortest")
21153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # netapi
21154ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            return shortest_name($2);
21155ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21156ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21157ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";# error
21158ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21159ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub shortest_name($)
21161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Name = $_[0];
21163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove prefix
21164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/\A(lib|open)//;
21165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # remove suffix
21166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/[\W\d_]+\Z//i;
21167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Name=~s/([a-z]{2,})(lib)\Z/$1/i;
21168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $Name;
21169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub createSymbolsList($$$$$)
21172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21173ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($DPath, $SaveTo, $LName, $LVersion, $ArchName) = @_;
21174ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    read_ABI_Dump(1, $DPath);
21175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckObjectsOnly) {
211761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        prepareSymbols(1);
21177ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21178ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %SymbolHeaderLib = ();
21179ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Total = 0;
21180ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Get List
21181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Symbol (sort keys(%{$CompleteSignature{1}}))
21182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not link_symbol($Symbol, 1, "-Deps"))
211841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
211871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(not symbolFilter($Symbol, 1, "Public", "Binary"))
21188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # skip other symbols
21189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21191ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $HeaderName = $CompleteSignature{1}{$Symbol}{"Header"};
21192ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $HeaderName)
211931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21194ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21195ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21196ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DyLib = $Symbol_Library{1}{$Symbol};
21197ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $DyLib)
211981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip src only and all external functions
21199ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            next;
21200ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21201ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SymbolHeaderLib{$HeaderName}{$DyLib}{$Symbol} = 1;
21202ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Total+=1;
21203ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21204ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # Draw List
21205ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $SYMBOLS_LIST = "<h1>Public symbols in <span style='color:Blue;'>$LName</span> (<span style='color:Red;'>$LVersion</span>)";
21206ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $SYMBOLS_LIST .= " on <span style='color:Blue;'>".showArch($ArchName)."</span><br/>Total: $Total</h1><br/>";
21207ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $HeaderName (sort {lc($a) cmp lc($b)} keys(%SymbolHeaderLib))
21208ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21209ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $DyLib (sort {lc($a) cmp lc($b)} keys(%{$SymbolHeaderLib{$HeaderName}}))
21210ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21211ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my %NS_Symbol = ();
21212ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $Symbol (keys(%{$SymbolHeaderLib{$HeaderName}{$DyLib}})) {
2121374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko                $NS_Symbol{select_Symbol_NS($Symbol, 1)}{$Symbol} = 1;
21214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21215ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            foreach my $NameSpace (sort keys(%NS_Symbol))
21216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
212171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                $SYMBOLS_LIST .= getTitle($HeaderName, $DyLib, $NameSpace);
21218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my @SortedInterfaces = sort {lc(get_Signature($a, 1)) cmp lc(get_Signature($b, 1))} keys(%{$NS_Symbol{$NameSpace}});
21219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                foreach my $Symbol (@SortedInterfaces)
21220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                {
21221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $SubReport = "";
21222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Signature = get_Signature($Symbol, 1);
21223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($NameSpace) {
2122462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                        $Signature=~s/\b\Q$NameSpace\E::\b//g;
21225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    if($Symbol=~/\A(_Z|\?)/)
21227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
212291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey 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");
212309927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                        }
21231ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21232ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21234ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21235ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    else
21236ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    {
21237ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        if($Signature) {
21238ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".highLight_Signature_Italic_Color($Signature)."</span><br/>\n";
21239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        else {
21241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                            $SubReport = "<span class='iname'>".$Symbol."</span><br/>\n";
21242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        }
21243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
21244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SYMBOLS_LIST .= $SubReport;
21245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SYMBOLS_LIST .= "<br/>\n";
21248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21249ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2125062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # clear info
2125162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    (%TypeInfo, %SymbolInfo, %Library_Symbol, %DepSymbol_Library,
2125262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %DepLibrary_Symbol, %SymVer, %SkipTypes, %SkipSymbols,
2125362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %NestedNameSpaces, %ClassMethods, %AllocableClass, %ClassNames,
2125462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    %CompleteSignature, %SkipNameSpaces, %Symbol_Library, %Library_Symbol) = ();
21255ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    ($Content_Counter, $ContentID) = (0, 0);
2125662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    # print report
212571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $CssStyles = readModule("Styles", "SymbolsList.css");
212581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $JScripts = readModule("Scripts", "Sections.js");
212591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = "<a name='Top'></a>".$SYMBOLS_LIST.$TOP_REF."<br/>\n";
21260ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Title = "$LName: public symbols";
21261ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Keywords = "$LName, API, symbols";
21262ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Description = "List of symbols in $LName ($LVersion) on ".showArch($ArchName);
212631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    $SYMBOLS_LIST = composeHTML_Head($Title, $Keywords, $Description, $CssStyles, $JScripts)."
21264ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <body><div>\n$SYMBOLS_LIST</div>
212659927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    <br/><br/><hr/>\n".getReportFooter($LName, 1)."
21266ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    <div style='height:999px;'></div></body></html>";
21267ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    writeFile($SaveTo, $SYMBOLS_LIST);
21268ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21269ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
212709927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub add_target_libs($)
212719927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
212729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    foreach (@{$_[0]}) {
212739927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        $TargetLibs{$_} = 1;
212749927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
212759927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
212769927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
21277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub is_target_lib($)
21278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LName = $_[0];
21280a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    if(not $LName) {
21281a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko        return 0;
21282a01311b923f49cc2c3d2769d308aeaf7832f6499Andrey Ponomarenko    }
21283ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibraryName
21284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $LName!~/\Q$TargetLibraryName\E/) {
21285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(keys(%TargetLibs)
21288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{$LName}
21289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $TargetLibs{parse_libname($LName, "name+ext", $OStarget)}) {
21290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return 0;
21291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 1;
21293ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21294ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21295850437949b65b213696469223d749c1f74c29601Andrey Ponomarenkosub is_target_header($$)
21296ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # --header, --headers-list
21297850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    my ($H, $V) = @_;
21298850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    if(keys(%{$TargetHeaders{$V}}))
21299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21300850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($TargetHeaders{$V}{$H}) {
21301850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            return 1;
21302ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21303ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21304850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    return 0;
21305ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21306ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21307ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub checkVersionNum($$)
21308ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21309ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Path) = @_;
21310ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(my $VerNum = $TargetVersion{$LibVersion}) {
21311ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $VerNum;
21312ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21313ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $UsedAltDescr = 0;
21314ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (split(/\s*,\s*/, $Path))
213151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # try to get version string from file path
213169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if(isDump($Part)); # ABI dump
213179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        next if($Part=~/\.(xml|desc)\Z/i); # XML descriptor
2131862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        my $VerNum = "";
2131962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(parse_libname($Part, "name", $OStarget))
21320ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21321ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $UsedAltDescr = 1;
2132262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $VerNum = parse_libname($Part, "version", $OStarget);
2132362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if(not $VerNum) {
2132407aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko                $VerNum = readStrVer($Part);
2132562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2132662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2132762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(is_header($Part, 2, $LibVersion) or -d $Part)
2132862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2132962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $UsedAltDescr = 1;
2133007aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $VerNum = readStrVer($Part);
2133162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2133262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($VerNum ne "")
2133362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2133462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            $TargetVersion{$LibVersion} = $VerNum;
2133562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($DumpAPI) {
21336570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                printMsg("WARNING", "setting version number to $VerNum (use -vnum option to change it)");
21337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
2133862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            else {
21339570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                printMsg("WARNING", "setting ".($LibVersion==1?"1st":"2nd")." version number to \"$VerNum\" (use -v$LibVersion option to change it)");
2134062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2134162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            return $TargetVersion{$LibVersion};
21342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UsedAltDescr)
21345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($DumpAPI) {
21347570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Error", "version number is not set (use -vnum option)");
21348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21350570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            exitStatus("Error", ($LibVersion==1?"1st":"2nd")." version number is not set (use -v$LibVersion option)");
21351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21353ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2135507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenkosub readStrVer($)
21356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Str = $_[0];
21358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "" if(not $Str);
21359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Str=~s/\Q$TargetLibraryName\E//g;
21360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Str=~/(\/|\\|\w|\A)[\-\_]*(\d+[\d\.\-]+\d+|\d+)/)
213611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # .../libssh-0.4.0/...
21362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $2;
21363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(my $V = parse_libname($Str, "version", $OStarget)) {
21365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $V;
21366ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return "";
21368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readLibs($)
21371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OStarget eq "windows")
21374ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # dumpbin.exe will crash
21375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        # without VS Environment
21376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        check_win32_env();
21377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
213781693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    readSymbols($LibVersion);
21379ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    translateSymbols(keys(%{$Symbol_Library{$LibVersion}}), $LibVersion);
2138062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    translateSymbols(keys(%{$DepSymbol_Library{$LibVersion}}), $LibVersion);
21381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub dump_sorting($)
21384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21385989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my $Hash = $_[0];
21386989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if(not $Hash);
21387989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    my @Keys = keys(%{$Hash});
21388989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    return [] if($#Keys<0);
21389989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    if($Keys[0]=~/\A\d+\Z/)
21390989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # numbers
21391989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {int($a)<=>int($b)} @Keys];
21392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21393989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    else
21394989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko    { # strings
21395989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko        return [sort {$a cmp $b} @Keys];
21396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printMsg($$)
21400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Type, $Msg) = @_;
21402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/\AINFO/) {
21403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg = $Type.": ".$Msg;
21404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Type!~/_C\Z/) {
21406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Msg .= "\n";
21407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet)
21409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet option
21410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($COMMON_LOG_PATH, $Msg);
21411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21414ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Type eq "ERROR") {
21415ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print STDERR $Msg;
21416ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21417ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21418ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            print $Msg;
21419ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21420ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21421ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21422ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21423ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitStatus($$)
21424ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21425ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($Code, $Msg) = @_;
21426ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("ERROR", $Msg);
21427ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exit($ERROR_CODE{$Code});
21428ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21429ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21430ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub exitReport()
21431ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # the tool has run without any errors
21432ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printReport();
21433ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($COMPILE_ERRORS)
21434ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # errors in headers may add false positives/negatives
21435ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compile_Error"});
21436ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
214371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $RESULT{"Binary"}{"Problems"})
214381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
214391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
214401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly and $RESULT{"Source"}{"Problems"})
214421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --source
214431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
214441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
214451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($RESULT{"Source"}{"Problems"}
214461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $RESULT{"Binary"}{"Problems"})
214471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
21448ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Incompatible"});
21449ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21450ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else {
21451ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($ERROR_CODE{"Compatible"});
21452ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21453ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21454ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21455ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub readRules($)
21456ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21457ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Kind = $_[0];
21458ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -f $RULES_PATH{$Kind}) {
21459ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Module_Error", "can't access \'".$RULES_PATH{$Kind}."\'");
21460ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21461ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $Content = readFile($RULES_PATH{$Kind});
21462ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    while(my $Rule = parseTag(\$Content, "rule"))
21463ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21464ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $RId = parseTag(\$Rule, "id");
21465ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @Properties = ("Severity", "Change", "Effect", "Overcome", "Kind");
21466ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Prop (@Properties) {
21467ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(my $Value = parseTag(\$Rule, lc($Prop)))
21468ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21469ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Value=~s/\n[ ]*//;
21470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CompatRules{$Kind}{$RId}{$Prop} = $Value;
21471ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21472ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CompatRules{$Kind}{$RId}{"Kind"}=~/\A(Symbols|Parameters)\Z/) {
21474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Symbols";
21475ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21476ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21477ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CompatRules{$Kind}{$RId}{"Kind"} = "Types";
21478ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21479ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21481ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
214821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub getReportPath($)
214831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
214841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
214851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = "compat_reports/$TargetLibraryName/".$Descriptor{1}{"Version"}."_to_".$Descriptor{2}{"Version"};
214861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary")
214871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
214881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath)
214891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --bin-report-path
214901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $BinaryReportPath;
214911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
214931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
214941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
214951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
214961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
214971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
214981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/abi_compat_report.$ReportFormat";
214991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source")
215021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath)
215041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --src-report-path
215051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $SourceReportPath;
215061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($OutputReportPath)
215081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
215091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
215101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
215121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
215131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/src_compat_report.$ReportFormat";
215141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215151bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
215171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
215191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
215201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $OutputReportPath;
215211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
215231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
215241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            return $Dir."/compat_report.$ReportFormat";
215251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
215281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
215291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub printStatMsg($)
215301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
215311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
215321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    printMsg("INFO", "total \"$Level\" compatibility problems: ".$RESULT{$Level}{"Problems"}.", warnings: ".$RESULT{$Level}{"Warnings"});
215331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
215341bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
215351bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub listAffected($)
215361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
215371bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
215381bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $List = "";
215391bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    foreach (keys(%{$TotalAffected{$Level}}))
215401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215411bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($StrictCompat and $TotalAffected{$Level}{$_} eq "Low")
215421bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # skip "Low"-severity problems
215431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            next;
215441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $List .= "$_\n";
215461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Dir = get_dirname(getReportPath($Level));
215481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
215491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/abi_affected.txt", $List);
215501bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215511bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($Level eq "Source") {
215521bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        writeFile($Dir."/src_affected.txt", $List);
215531bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
215541bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
215551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printReport()
21557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating compatibility report ...");
215591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    createReport();
215601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
215611bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}
215631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        or $RESULT{"Source"}{"Problems"}) {
215641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (Binary: ".$RESULT{"Binary"}{"Affected"}."\%, Source: ".$RESULT{"Source"}{"Affected"}."\%)");
215651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
215671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
215681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
215701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
215711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
215721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
215731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
215741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
21575ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21576ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
215771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly)
215781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Binary"}{"Problems"}) {
215801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Binary"}{"Affected"}."\%)");
215811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
215831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
215841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Binary");
215861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
215871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
215881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Binary");
215891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21590ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
215911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly)
215921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
215931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($RESULT{"Source"}{"Problems"}) {
215941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: INCOMPATIBLE (".$RESULT{"Source"}{"Affected"}."\%)");
215951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else {
215971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "result: COMPATIBLE");
215981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
215991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printStatMsg("Source");
216001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ListAffected)
216011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --list-affected
216021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            listAffected("Source");
216031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21604ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
216051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($StdOut)
216061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport or not $DoubleReport)
216080d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        { # --binary or --source
216091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility report has been generated to stdout");
216101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        else
216121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
216131bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "compatibility reports have been generated to stdout");
216141bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21615ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
216161bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
216171bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
216181bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($JoinReport)
216190d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        {
216201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Join"));
216211bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216221bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($DoubleReport)
216231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # default
216241bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed reports:\n  ".getReportPath("Binary")."\n  ".getReportPath("Source"));
216251bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216261bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($BinaryOnly)
216271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --binary
216281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Binary"));
216291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
216301bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($SourceOnly)
216311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --source
216321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            printMsg("INFO", "see detailed report:\n  ".getReportPath("Source"));
216331bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
21634ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub check_win32_env()
21638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21639ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $ENV{"DevEnvDir"}
21640ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $ENV{"LIB"}) {
21641ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't start without VS environment (vsvars32.bat)");
21642ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21643ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21644ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
216455c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenkosub diffSets($$)
216465c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko{
216475c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my ($S1, $S2) = @_;
216485c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK1 = keys(%{$S1});
216495c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my @SK2 = keys(%{$S2});
216505c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($#SK1!=$#SK2) {
216515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        return 1;
216525c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
216535c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    foreach my $K1 (@SK1)
216545c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
216555c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not defined $S2->{$K1}) {
216565c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            return 1;
216575c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
216585c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
216595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    return 0;
216605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko}
216615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub create_ABI_Dump()
21663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not -e $DumpAPI) {
21665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Access_Error", "can't access \'$DumpAPI\'");
21666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @DParts = split(/\s*,\s*/, $DumpAPI);
21668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts)
21669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Part) {
21671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Part\'");
21672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    checkVersionNum(1, $DumpAPI);
21675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts)
21676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21677ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isDump($Part)) {
21678ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            read_ABI_Dump(1, $Part);
21679ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21680ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
21681ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readDescriptor(1, createDescriptor(1, $Part));
21682ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21683ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21684fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21685fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
21686fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
21687fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
21688fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21689fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
21691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("inc|lib|bin|gcc"); # complete analysis
2169274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
216938f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $DumpPath = "abi_dumps/$TargetLibraryName/".$TargetLibraryName."_".$Descriptor{1}{"Version"}.".abi";
216948f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    $DumpPath .= ".".$AR_EXT; # gzipped by default
216958f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($OutputDumpPath)
216968f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # user defined path
216978f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $DumpPath = $OutputDumpPath;
2169874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
216998f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    my $Archive = ($DumpPath=~s/\Q.$AR_EXT\E\Z//g);
217008f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko
217018f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if(not $Archive and not $StdOut)
217028f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # check archive utilities
217038f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        if($OSgroup eq "windows")
217048f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using zip
217058f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $ZipCmd = get_CmdPath("zip");
217068f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $ZipCmd) {
217078f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"zip\"");
217088f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2170974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
217108f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        else
217118f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        { # using tar and gzip
217128f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $TarCmd = get_CmdPath("tar");
217138f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $TarCmd) {
217148f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"tar\"");
217158f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
217168f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            my $GzipCmd = get_CmdPath("gzip");
217178f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            if(not $GzipCmd) {
217188f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko                exitStatus("Not_Found", "can't find \"gzip\"");
217198f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko            }
2172074b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
2172174b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
2172274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2172301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2172401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2172501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckHeadersOnly) {
2172601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readLibs(1);
2172701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2172801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($CheckHeadersOnly) {
2172901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            setLanguage(1, "C++");
2173001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2173101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if(not $CheckObjectsOnly) {
2173201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            searchForHeaders(1);
2173301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
2173401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize();
21735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2173601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
2173701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    {
2173801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        if($Descriptor{1}{"Headers"}) {
2173901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            readHeaders(1);
2174001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        }
21741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21742850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    cleanDump(1);
21743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not keys(%{$SymbolInfo{1}}))
21744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # check if created dump is valid
21745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $ExtendedCheck and not $CheckObjectsOnly)
21746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
21747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CheckHeadersOnly) {
21748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Set", "the set of public symbols is empty");
21749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
21751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Empty_Intersection", "the sets of public symbols in headers and libraries have empty intersection");
21752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %HeadersInfo = ();
21756fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $HPath (keys(%{$Registered_Headers{1}})) {
21757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $HeadersInfo{$Registered_Headers{1}{$HPath}{"Identity"}} = $Registered_Headers{1}{$HPath}{"Pos"};
21758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21759570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ExtraDump)
21760570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    { # add unmangled names to the ABI dump
21761570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        my @Names = ();
21762570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21763570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21764570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"}) {
21765570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push(@Names, $MnglName);
21766570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21767570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21768570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        translateSymbols(@Names, 1);
21769570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        foreach my $InfoId (keys(%{$SymbolInfo{1}}))
21770570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        {
21771570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            if(my $MnglName = $SymbolInfo{1}{$InfoId}{"MnglName"})
21772570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            {
21773570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                if(my $Unmangled = $tr_name{$MnglName})
21774570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                {
21775570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    if($MnglName ne $Unmangled) {
21776570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                        $SymbolInfo{1}{$InfoId}{"Unmangled"} = $Unmangled;
21777570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                    }
21778570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                }
21779570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko            }
21780570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        }
21781570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
21782fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21783fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    my %GccConstants = (); # built-in GCC constants
21784fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    foreach my $Name (keys(%{$Constants{1}}))
21785fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
21786fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not defined $Constants{1}{$Name}{"Header"})
21787fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        {
21788fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $GccConstants{$Name} = $Constants{1}{$Name}{"Value"};
21789fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            delete($Constants{1}{$Name});
21790fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
21791fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
21792fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
21793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "creating library ABI dump ...");
2179401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    my %ABI = (
21795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "TypeInfo" => $TypeInfo{1},
21796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolInfo" => $SymbolInfo{1},
21797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Symbols" => $Library_Symbol{1},
2179862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        "DepSymbols" => $DepLibrary_Symbol{1},
21799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SymbolVersion" => $SymVer{1},
21800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryVersion" => $Descriptor{1}{"Version"},
21801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "LibraryName" => $TargetLibraryName,
21802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Language" => $COMMON_LANGUAGE{1},
21803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipTypes" => $SkipTypes{1},
21804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipSymbols" => $SkipSymbols{1},
21805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipNameSpaces" => $SkipNameSpaces{1},
21806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "SkipHeaders" => $SkipHeadersList{1},
21807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Headers" => \%HeadersInfo,
21808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Constants" => $Constants{1},
21809fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        "GccConstants" => \%GccConstants,
21810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "NameSpaces" => $NestedNameSpaces{1},
21811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Target" => $OStarget,
21812ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "Arch" => getArch(1),
21813ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "WordSize" => $WORD_SIZE{1},
21814ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "GccVersion" => get_dumpversion($GCC_PATH),
21815ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_DUMP_VERSION" => $ABI_DUMP_VERSION,
21816ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        "ABI_COMPLIANCE_CHECKER_VERSION" => $TOOL_VERSION
21817ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
218185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if(diffSets($TargetHeaders{1}, \%HeadersInfo)) {
2181901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"TargetHeaders"} = $TargetHeaders{1};
218205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
218215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML) {
2182201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"XML_ABI_DUMP_VERSION"} = $XML_ABI_DUMP_VERSION;
218235c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
21824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck)
21825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --ext option
2182601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"Mode"} = "Extended";
21827ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
218281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly)
218291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary
2183001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI{"BinOnly"} = 1;
218311bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
2183274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    if($ExtraDump)
21833fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # --extra-dump
2183474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        $ABI{"Extra"} = 1;
21835fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"UndefinedSymbols"} = $UndefinedSymbols{1};
21836fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $ABI{"Needed"} = $Library_Needed{1};
2183774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko    }
218385c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
218395c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    my $ABI_DUMP = "";
218405c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($UseXML)
218415c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    {
218425c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        loadModule("XmlDump");
2184301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = createXmlDump(\%ABI);
218445c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
218451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
218461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # default
2184701117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko        $ABI_DUMP = Dumper(\%ABI);
218481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
21849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
21850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --stdout option
218515c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print STDOUT $ABI_DUMP;
21852ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI dump has been generated to stdout");
21853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return;
21854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
21856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # write to gzipped file
21857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my ($DDir, $DName) = separate_path($DumpPath);
21858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $DPath = $TMP_DIR."/".$DName;
218595c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if(not $Archive) {
218605c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $DPath = $DumpPath;
218615c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
218625c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko
21863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($DDir);
21864850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21865850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        open(DUMP, ">", $DPath) || die ("can't open file \'$DPath\': $!\n");
218665c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        print DUMP $ABI_DUMP;
21867850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        close(DUMP);
21868850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -s $DPath) {
21870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't create ABI dump because something is going wrong with the Data::Dumper module");
21871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2187207aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko        if($Archive) {
2187307aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko            $DumpPath = createArchive($DPath, $DDir);
218745c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
2187507aea0703ddcc68b96ff2e0ca53a742d2e9c6f9bAndrey Ponomarenko
21876ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        if($OutputDumpPath) {
21877ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $OutputDumpPath");
21878ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        }
21879ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        else {
218805c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            printMsg("INFO", "library ABI has been dumped to:\n  $DumpPath");
218815c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
21882ed17838a1f33d5b9f525b359c9e481722a8962a9Andrey Ponomarenko        printMsg("INFO", "you can transfer this dump everywhere and use instead of the ".$Descriptor{1}{"Version"}." version descriptor");
21883ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21884ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21885ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21886ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub quickEmptyReports()
21887ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{ # Quick "empty" reports
21888ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # 4 times faster than merging equal dumps
21889ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # NOTE: the dump contains the "LibraryVersion" attribute
21890ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # if you change the version, then your dump will be different
21891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME: use -v1 and v2 options for comparing dumps
21892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # and don't change version in the XML descriptor (and dumps)
21893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko  # OVERCOME 2: separate meta info from the dumps in ACC 2.0
21894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(-s $Descriptor{1}{"Path"} == -s $Descriptor{2}{"Path"})
21895ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
21896ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath1 = unpackDump($Descriptor{1}{"Path"});
21897ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $FilePath2 = unpackDump($Descriptor{2}{"Path"});
21898ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($FilePath1 and $FilePath2)
21899ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
2190001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            my $Line = readLineNum($FilePath1, 0);
2190101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($Line=~/xml/)
2190201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            { # XML format
2190301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                # is not supported yet
2190401117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                return;
2190501117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
2190601117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko
21907850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            local $/ = undef;
21908850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21909850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP1, $FilePath1);
21910850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content1 = <DUMP1>;
21911850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP1);
21912850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21913850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            open(DUMP2, $FilePath2);
21914850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            my $Content2 = <DUMP2>;
21915850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            close(DUMP2);
21916850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21917850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Content1 eq $Content2)
21918ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
21919850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21920850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content2;
21921850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21922ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                # read a number of headers, libs, symbols and types
21923850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                my $ABIdump = eval($Content1);
21924850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21925850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                # clean memory
21926850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                undef $Content1;
21927850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
21928ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump) {
219299927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko                    exitStatus("Error", "internal error - eval() procedure seem to not working correctly, try to remove 'use strict' and try again");
21930ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21931ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"TypeInfo"})
219321bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21933ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"TypeInfo"} = $ABIdump->{"TypeDescr"};
21934ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21935ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                if(not $ABIdump->{"SymbolInfo"})
219361bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                { # support for old dumps
21937ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $ABIdump->{"SymbolInfo"} = $ABIdump->{"FuncDescr"};
21938ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
21939fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko                read_Source_DumpInfo($ABIdump, 1);
21940ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Libs_DumpInfo($ABIdump, 1);
21941ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 1);
21942ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                read_Machine_DumpInfo($ABIdump, 2);
219431bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
219441bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Binary"}} = %{$ABIdump->{"TypeInfo"}};
219451bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedTypes{"Source"}} = %{$ABIdump->{"TypeInfo"}};
219461bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
219471bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Binary"}} = %{$ABIdump->{"SymbolInfo"}};
219481bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko                %{$CheckedSymbols{"Source"}} = %{$ABIdump->{"SymbolInfo"}};
219491bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
21950ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{1}{"Version"} = $TargetVersion{1}?$TargetVersion{1}:$ABIdump->{"LibraryVersion"};
21951ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $Descriptor{2}{"Version"} = $TargetVersion{2}?$TargetVersion{2}:$ABIdump->{"LibraryVersion"};
21952ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitReport();
21953ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
21954ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
21955ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21956ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21957ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21958ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub initLogging($)
21959ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21960ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21961ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # create log directory
21962ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LOG_DIR, $LOG_FILE) = ("logs/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"}, "log.txt");
21963ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($OutputLogPath{$LibVersion})
21964ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user-defined by -log-path option
21965ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        ($LOG_DIR, $LOG_FILE) = separate_path($OutputLogPath{$LibVersion});
21966ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21967ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21968ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        mkpath($LOG_DIR);
21969ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21970ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $LOG_PATH{$LibVersion} = get_abs_path($LOG_DIR)."/".$LOG_FILE;
21971ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Debug)
21972ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # debug directory
21973ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $DEBUG_PATH{$LibVersion} = "debug/$TargetLibraryName/".$Descriptor{$LibVersion}{"Version"};
2197474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2197574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not $ExtraInfo)
2197674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        { # enable --extra-info
2197774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            $ExtraInfo = $DEBUG_PATH{$LibVersion}."/extra-info";
2197874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        }
21979ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
2198035c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko    resetLogging($LibVersion);
21981ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21982ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21983ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub writeLog($$)
21984ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21985ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my ($LibVersion, $Msg) = @_;
21986ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
21987ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        appendFile($LOG_PATH{$LibVersion}, $Msg);
21988ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
21989ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
21990ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
21991ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub resetLogging($)
21992ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
21993ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
21994ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode!~/a|n/)
21995ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # remove old log
21996ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        unlink($LOG_PATH{$LibVersion});
2199735c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Debug) {
2199835c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko            rmtree($DEBUG_PATH{$LibVersion});
2199935c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        }
22000ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22001ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22002ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22003ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub printErrorLog($)
22004ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22005ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my $LibVersion = $_[0];
22006ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LogMode ne "n") {
22007ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("ERROR", "see log for details:\n  ".$LOG_PATH{$LibVersion}."\n");
22008ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22009ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22010ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22011ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub isDump($)
22012ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22013fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.tar\.gz|\.zip|\.xml|)(\.\w+|)\Z/) {
220149927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        return $1;
220159927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    }
220169927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    return 0;
220179927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko}
220189927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
220199927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub isDump_U($)
220209927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko{
22021fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(get_filename($_[0])=~/\A(.+)\.(abi|abidump|dump)(\.xml|)(\.\w+|)\Z/) {
22022ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        return $1;
22023ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22024ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return 0;
22025ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22026ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
220271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareInit()
22028ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22029ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # read input XML descriptors or ABI dumps
22030ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Path"}) {
220310d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-old option is not specified");
22032ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22033ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @DParts1 = split(/\s*,\s*/, $Descriptor{1}{"Path"});
22034ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts1)
22035ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22036ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Part) {
22037ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Part\'");
22038ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22039ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22040ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Path"}) {
220410d5917f800bbc0a5f0d38de1b8b16c12294093f0Andrey Ponomarenko        exitStatus("Error", "-new option is not specified");
22042ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22043ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my @DParts2 = split(/\s*,\s*/, $Descriptor{2}{"Path"});
22044ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts2)
22045ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22046ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $Part) {
22047ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$Part\'");
22048ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22049ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22050ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    detect_default_paths("bin"); # to extract dumps
22051ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($#DParts1==0 and $#DParts2==0
22052ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{1}{"Path"})
22053ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and isDump($Descriptor{2}{"Path"}))
22054ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # optimization: equal ABI dumps
22055ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        quickEmptyReports();
22056ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22057ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    checkVersionNum(1, $Descriptor{1}{"Path"});
22058ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    checkVersionNum(2, $Descriptor{2}{"Path"});
22059ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    printMsg("INFO", "preparation, please wait ...");
22060ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts1)
22061ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22062ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isDump($Part)) {
22063ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            read_ABI_Dump(1, $Part);
22064ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22065ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22066ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readDescriptor(1, createDescriptor(1, $Part));
22067ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22068ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22069ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    foreach my $Part (@DParts2)
22070ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22071ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(isDump($Part)) {
22072ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            read_ABI_Dump(2, $Part);
22073ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22074ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22075ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readDescriptor(2, createDescriptor(2, $Part));
22076ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22077ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22078fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22079fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{1}{"Version"})
22080fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: X
22081fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{1}{"Version"} = "X";
22082fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22083fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22084fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if(not $Descriptor{2}{"Version"})
22085fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    { # set to default: Y
22086fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        $Descriptor{2}{"Version"} = "Y";
22087fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22088fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko
22089ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(1);
22090ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    initLogging(2);
22091ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # check consistency
22092ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}
22093ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $Descriptor{1}{"Libs"}) {
22094ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "descriptor d1 does not contain both header files and libraries info");
22095ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22096ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"}
22097ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $Descriptor{2}{"Libs"}) {
22098ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "descriptor d2 does not contain both header files and libraries info");
22099ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22100ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Headers"} and not $Descriptor{1}{"Libs"}
22101ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $Descriptor{2}{"Headers"} and $Descriptor{2}{"Libs"}) {
22102ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't compare headers with $SLIB_TYPE libraries");
22103ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22104ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $Descriptor{1}{"Headers"} and $Descriptor{1}{"Libs"}
22105ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and $Descriptor{2}{"Headers"} and not $Descriptor{2}{"Libs"}) {
22106ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "can't compare $SLIB_TYPE libraries with headers");
22107ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22108bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"})
22109bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22110ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly_Opt) {
22111ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find header files info in descriptor d1");
22112ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22113ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22114bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{2}{"Headers"})
22115bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22116ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly_Opt) {
22117ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find header files info in descriptor d2");
22118ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22119ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22120ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Headers"}
22121bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    or not $Descriptor{2}{"Headers"})
22122bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22123bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        if(not $CheckObjectsOnly_Opt)
22124bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko        {
22125ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "comparing $SLIB_TYPE libraries only");
22126ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckObjectsOnly = 1;
22127ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22128ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22129bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{1}{"Libs"})
22130bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22131ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckObjectsOnly_Opt) {
22132ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find $SLIB_TYPE libraries info in descriptor d1");
22133ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22134ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22135bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    if(not $Descriptor{2}{"Libs"})
22136bdc85a93759276de06596588bf55aebee6289315Andrey Ponomarenko    {
22137ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckObjectsOnly_Opt) {
22138ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "can't find $SLIB_TYPE libraries info in descriptor d2");
22139ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22140ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22141ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Libs"}
22142ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Libs"})
22143ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # comparing standalone header files
22144ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # comparing ABI dumps created with --headers-only
22145ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly_Opt)
22146ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22147ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "checking headers only");
22148ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $CheckHeadersOnly = 1;
22149ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22150ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22151ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UseDumps)
22152ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --use-dumps
22153ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # parallel processing
2215474b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $DumpPath1 = "abi_dumps/$TargetLibraryName/".$TargetLibraryName."_".$Descriptor{1}{"Version"}.".abi.$AR_EXT";
2215574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        my $DumpPath2 = "abi_dumps/$TargetLibraryName/".$TargetLibraryName."_".$Descriptor{2}{"Version"}.".abi.$AR_EXT";
2215674b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
2215774b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath1);
2215874b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        unlink($DumpPath2);
2215974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko
22160ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my $pid = fork();
22161ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($pid)
22162ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # dump on two CPU cores
22163ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{1}{"Path"}, "-l", $TargetLibraryName);
22164ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{1}) {
22165ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{1});
22166ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22167ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{1}) {
22168ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{1});
22169ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22170ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22171ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22172ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22173dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22174dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22175ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22176dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22177dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22178dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22179dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22180dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22181ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22182ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22183ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22184ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22185ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22186ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22187ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22188ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{1}) {
22189ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{1});
22190ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22191850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22192850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22193850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22194850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22195850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22196850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2219762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2219862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2219962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2220001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2220101117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2220201117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22203f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22204f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22205f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22206f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckObjectsOnly) {
22207f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-objects-only");
22208f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22209850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22210850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22211850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2221262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22213850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22214ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2221574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath1) {
22216ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22217ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22218ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22219ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else
22220ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # child
22221ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my @PARAMS = ("-dump", $Descriptor{2}{"Path"}, "-l", $TargetLibraryName);
22222ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($RelativeDirectory{2}) {
22223ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-relpath", $RelativeDirectory{2});
22224ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22225ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($OutputLogPath{2}) {
22226ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-log-path", $OutputLogPath{2});
22227ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22228ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($CrossGcc) {
22229ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-cross-gcc", $CrossGcc);
22230ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22231dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            if($Quiet)
22232dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            {
22233ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-quiet");
22234dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", "a");
22235dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            }
22236dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            elsif($LogMode and $LogMode ne "w")
22237dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko            { # "w" is default
22238dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko                @PARAMS = (@PARAMS, "-logging-mode", $LogMode);
22239ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22240ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($ExtendedCheck) {
22241ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-extended");
22242ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22243ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($UserLang) {
22244ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-lang", $UserLang);
22245ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22246ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($TargetVersion{2}) {
22247ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                @PARAMS = (@PARAMS, "-vnum", $TargetVersion{2});
22248ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22249850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($BinaryOnly) {
22250850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-binary");
22251850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22252850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($SourceOnly) {
22253850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-source");
22254850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
2225562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            if($SortDump) {
2225662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                @PARAMS = (@PARAMS, "-sort");
2225762ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            }
2225801117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            if($DumpFormat and $DumpFormat ne "perl") {
2225901117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko                @PARAMS = (@PARAMS, "-dump-format", $DumpFormat);
2226001117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko            }
22261f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckHeadersOnly) {
22262f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-headers-only");
22263f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22264f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            if($CheckObjectsOnly) {
22265f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko                @PARAMS = (@PARAMS, "-objects-only");
22266f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            }
22267850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            if($Debug)
22268850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            {
22269850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko                @PARAMS = (@PARAMS, "-debug");
2227062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                printMsg("INFO", "running perl $0 @PARAMS");
22271850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            }
22272ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            system("perl", $0, @PARAMS);
2227374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko            if(not -f $DumpPath2) {
22274ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(1);
22275ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22276ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            else {
22277ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exit(0);
22278ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22279ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22280ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        waitpid($pid, 0);
22281ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        my @CMP_PARAMS = ("-l", $TargetLibraryName);
2228274b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d1", $DumpPath1);
2228374b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-d2", $DumpPath2);
22284ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryFName ne $TargetLibraryName) {
22285ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-l-full", $TargetLibraryFName);
22286ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22287ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($ShowRetVal) {
22288ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-show-retval");
22289ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22290ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CrossGcc) {
22291ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-cross-gcc", $CrossGcc);
22292ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2229335c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        @CMP_PARAMS = (@CMP_PARAMS, "-logging-mode", "a");
2229435c44fd1428ba96f71ba80f1d45c175a9ab4a197Andrey Ponomarenko        if($Quiet) {
22295ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-quiet");
22296dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        }
22297dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        if($ReportFormat and $ReportFormat ne "html")
22298dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        { # HTML is default format
22299ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-format", $ReportFormat);
22300ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
223011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath) {
223021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-report-path", $OutputReportPath);
223031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($BinaryReportPath) {
223051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-bin-report-path", $BinaryReportPath);
223061bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223071bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($SourceReportPath) {
223081bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-src-report-path", $SourceReportPath);
223091bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
223101bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($LoggingPath) {
223111bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-log-path", $LoggingPath);
223121bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22313f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckHeadersOnly) {
22314f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-headers-only");
22315f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22316f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($CheckObjectsOnly) {
22317f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-objects-only");
22318f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22319f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($BinaryOnly) {
22320f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-binary");
22321f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22322f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        if($SourceOnly) {
22323f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-source");
22324f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        }
22325850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if($Browse) {
22326850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-browse", $Browse);
22327850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
2232862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($OpenReport) {
2232962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-open");
2233062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        }
2233162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if($Debug)
2233262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        {
2233362ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            @CMP_PARAMS = (@CMP_PARAMS, "-debug");
2233462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko            printMsg("INFO", "running perl $0 @CMP_PARAMS");
22335850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        }
22336ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        system("perl", $0, @CMP_PARAMS);
22337ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($?>>8);
22338ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22339ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"}
22340ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or not $Descriptor{2}{"Dump"})
22341ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # need GCC toolchain to analyze
22342ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # header files and libraries
22343ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("inc|lib|gcc");
22344ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22345ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{1}{"Dump"})
22346ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22347ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22348ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(1);
22349ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22350ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22351ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(1, "C++");
22352ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22353850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $CheckObjectsOnly) {
22354ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            searchForHeaders(1);
22355ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22356ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $WORD_SIZE{1} = detectWordSize();
22357ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22358ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $Descriptor{2}{"Dump"})
22359ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22360ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not $CheckHeadersOnly) {
22361ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readLibs(2);
22362ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22363ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($CheckHeadersOnly) {
22364ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            setLanguage(2, "C++");
22365ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22366850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko        if(not $CheckObjectsOnly) {
22367ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            searchForHeaders(2);
22368ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22369ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $WORD_SIZE{2} = detectWordSize();
22370ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22371ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($WORD_SIZE{1} ne $WORD_SIZE{2})
22372ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22373ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # try to synch different WORD sizes
2237462ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        if(not checkDump(1, "2.1"))
22375ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22376ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{1} = $WORD_SIZE{2};
22377ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{2}." bytes");
22378ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
2237962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        elsif(not checkDump(2, "2.1"))
22380ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22381ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $WORD_SIZE{2} = $WORD_SIZE{1};
22382ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            printMsg("WARNING", "set WORD size to ".$WORD_SIZE{1}." bytes");
22383ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22384ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22385ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    elsif(not $WORD_SIZE{1}
22386ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    and not $WORD_SIZE{2})
22387ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
2238862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{1} = "4";
2238962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $WORD_SIZE{2} = "4";
22390ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22391ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{1}{"Dump"})
22392ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22393ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(1);
22394ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22395ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Descriptor{2}{"Dump"})
22396ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # support for old ABI dumps
22397ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        prepareTypes(2);
22398ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22399ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath and not keys(%{$Symbol_Library{1}})) {
22400ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("WARNING", "the application ".get_filename($AppPath)." has no symbols imported from the $SLIB_TYPE libraries");
22401ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22402ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # started to process input data
22403ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $CheckObjectsOnly)
22404ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22405ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{1}{"Headers"}
22406ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $Descriptor{1}{"Dump"}) {
22407ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readHeaders(1);
22408ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22409ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Descriptor{2}{"Headers"}
22410ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        and not $Descriptor{2}{"Dump"}) {
22411ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readHeaders(2);
22412ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22413ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22414850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
22415850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
22416850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %SystemHeaders = ();
22417850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    %mangled_name_gcc = ();
22418850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko
224191bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(1);
224201bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    prepareSymbols(2);
224211693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
22422850437949b65b213696469223d749c1f74c29601Andrey Ponomarenko    # clean memory
224231bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    %SymbolInfo = ();
224241693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224251693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Virtual Tables
224261693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(1);
224271693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerVTable(2);
224281693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
2242962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if(not checkDump(1, "1.22")
2243062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    and checkDump(2, "1.22"))
224311693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    { # support for old ABI dumps
224321693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $ClassName (keys(%{$VirtualTable{2}}))
224331693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        {
224341693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            if($ClassName=~/</)
224351693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            { # templates
224361693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                if(not defined $VirtualTable{1}{$ClassName})
224371693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                { # synchronize
224381693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                    delete($VirtualTable{2}{$ClassName});
224391693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko                }
224401693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko            }
224411693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        }
224421693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    }
224431693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224441693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(1);
224451693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    registerOverriding(2);
224461693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224471693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(1);
224481693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    setVirtFuncPositions(2);
224491693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224501693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    # Other
224511693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(1);
224521693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    addParamNames(2);
224531693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko
224541693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko    detectChangedTypedefs();
224551bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko}
224561bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko
224571bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenkosub compareAPIs($)
224581bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko{
224591bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    my $Level = $_[0];
224601bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    readRules($Level);
22461f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko    loadModule("CallConv");
224621bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($Level eq "Binary") {
224631bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing ABIs ...");
224641bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
224651bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else {
224661bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        printMsg("INFO", "comparing APIs ...");
224671bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
224681bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
224691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
22470ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # added/removed in headers
224711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded_H($Level);
224721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved_H($Level);
22473ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22474ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
224751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
224761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectAdded($Level);
224771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        detectRemoved($Level);
224781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
224791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if(not $CheckObjectsOnly)
22480ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
224818f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        mergeSymbols($Level);
224821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if(keys(%{$CheckedSymbols{$Level}})) {
224831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            mergeConstants($Level);
224841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
224851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22486f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
22487f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko    $Cache{"mergeTypes"} = (); # free memory
22488f442c17449649492e74594fcd3d7fc3b3965bfc4Andrey Ponomarenko
224891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($CheckHeadersOnly
224901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    or $Level eq "Source")
224911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in headers
224921bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeHeaders($Level);
224931bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
224941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    else
224951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # added/removed in libs
224961bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        mergeLibs($Level);
224971bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($CheckImpl
224981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        and $Level eq "Binary") {
22499ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            mergeImpl();
22500ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22501ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22502ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22503ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
225049927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenkosub getSysOpts()
22505ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22506ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %Opts = (
22507ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "OStarget"=>$OStarget,
22508ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Debug"=>$Debug,
22509ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "Quiet"=>$Quiet,
22510ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "LogMode"=>$LogMode,
22511ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CheckHeadersOnly"=>$CheckHeadersOnly,
22512ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22513ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "SystemRoot"=>$SystemRoot,
22514ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "MODULES_DIR"=>$MODULES_DIR,
22515ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "GCC_PATH"=>$GCC_PATH,
22516ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetSysInfo"=>$TargetSysInfo,
22517ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossPrefix"=>$CrossPrefix,
22518ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "TargetLibraryName"=>$TargetLibraryName,
22519ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "CrossGcc"=>$CrossGcc,
22520ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    "UseStaticLibs"=>$UseStaticLibs,
225219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "NoStdInc"=>$NoStdInc,
225229927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko
225239927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "BinaryOnly" => $BinaryOnly,
225249927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko    "SourceOnly" => $SourceOnly
22525ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    );
22526ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return \%Opts;
22527ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22528ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
2252974b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenkosub get_CodeError($)
22530ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22531ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    my %CODE_ERROR = reverse(%ERROR_CODE);
22532ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    return $CODE_ERROR{$_[0]};
22533ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22534ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22535ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkosub scenario()
22536ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko{
22537ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($StdOut)
22538ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # enable quiet mode
22539ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $Quiet = 1;
225401bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 1;
22541ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22542dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    if(not $LogMode)
22543dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    { # default
22544dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko        $LogMode = "w";
22545dde2dad52c969ebc1e385d4c759055c0c05fb433Andrey Ponomarenko    }
22546ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($UserLang)
22547ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --lang=C++
22548ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $UserLang = uc($UserLang);
22549ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{1}=$UserLang;
22550ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $COMMON_LANGUAGE{2}=$UserLang;
22551ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22552ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($LoggingPath)
22553ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22554ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{1} = $LoggingPath;
22555ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $OutputLogPath{2} = $LoggingPath;
22556ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($Quiet) {
22557ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $COMMON_LOG_PATH = $LoggingPath;
22558ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22559ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22560e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    if($Quick) {
22561e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko        $ADD_TMPL_INSTANCES = 0;
22562e3a8d81ab0e2aeefe91205d96c2edeec14749ec7Andrey Ponomarenko    }
225635c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($OutputDumpPath)
225645c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
2256574b33ee9348fd163e65f1879e860c7067ae2f61fAndrey Ponomarenko        if(not isDump($OutputDumpPath)) {
225665c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "the dump path should be a path to *.abi.$AR_EXT or *.abi file");
225675c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
225685c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
225691bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($BinaryOnly and $SourceOnly)
225701bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # both --binary and --source
225711bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko      # is the default mode
225721bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 1;
225731bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
225741bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $BinaryOnly = 0;
225751bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $SourceOnly = 0;
225761bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($OutputReportPath)
225771bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-path
225781bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $DoubleReport = 0;
225791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $JoinReport = 1;
225801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
225811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
225821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly or $SourceOnly)
225831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --binary or --source
225841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $DoubleReport = 0;
225851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $JoinReport = 0;
225861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
225871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($UseXML)
225881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    { # --xml option
225891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = "xml";
225905c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "xml";
225911bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22592ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ReportFormat)
22593ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate
225941bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        $ReportFormat = lc($ReportFormat);
225951bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat!~/\A(xml|html|htm)\Z/) {
225965c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown report format \'$ReportFormat\'");
22597ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
225981bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        if($ReportFormat eq "htm")
225991bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # HTM == HTML
226001bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $ReportFormat = "html";
226011bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
226021bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        elsif($ReportFormat eq "xml")
226031bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # --report-format=XML equal to --xml
226041bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $UseXML = 1;
226051bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        }
22606ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22607ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22608ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # default: HTML
22609ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $ReportFormat = "html";
22610ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226115c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    if($DumpFormat)
226125c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    { # validate
226135c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = lc($DumpFormat);
226145c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat!~/\A(xml|perl)\Z/) {
226155c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            exitStatus("Error", "unknown ABI dump format \'$DumpFormat\'");
226165c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
226175c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        if($DumpFormat eq "xml")
226185c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        { # --dump-format=XML equal to --xml
226195c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko            $UseXML = 1;
226205c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        }
226215c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
226225c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    else
2262301117f17f0064f91d93bfd2dafe8fcd36e636f33Andrey Ponomarenko    { # default: Perl Data::Dumper
226245c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko        $DumpFormat = "perl";
226255c09ef3aadb39afc16c59258feebbee1e49609d9Andrey Ponomarenko    }
22626ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($Quiet and $LogMode!~/a|n/)
22627ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --quiet log
22628ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(-f $COMMON_LOG_PATH) {
22629ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            unlink($COMMON_LOG_PATH);
22630ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22631ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226324b077f8c68e147aca2f2275cc18ca053020b5312Andrey Ponomarenko    if($ExtraInfo) {
22633570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        $CheckUndefined = 1;
22634570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    }
22635ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool and $UseDumps)
22636ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test && --use-dumps == --test-dump
22637ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TestDump = 1;
22638ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
226398f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    if($Tolerant)
226408f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    { # enable all
226418f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko        $Tolerance = 1234;
226428f4b981ae1f0ff8962e14c17229f6fc512d12f6aAndrey Ponomarenko    }
22643570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($Help)
22644570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22645ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        HELP_MESSAGE();
22646ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22647ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22648ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($InfoMsg) {
22649ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        INFO_MESSAGE();
22650ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22651ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22652570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($ShowVersion)
22653570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22654ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", "ABI Compliance Checker (ACC) $TOOL_VERSION\nCopyright (C) 2012 ROSA 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.");
22655ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22656ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22657570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($DumpVersion)
22658570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22659ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        printMsg("INFO", $TOOL_VERSION);
22660ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22661ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22662ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ExtendedCheck) {
22663ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $CheckHeadersOnly = 1;
22664ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22665ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SystemRoot_Opt)
22666ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # user defined root
22667ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -e $SystemRoot_Opt) {
22668ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access \'$SystemRoot\'");
22669ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22670ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot = $SystemRoot_Opt;
22671ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $SystemRoot=~s/[\/]+\Z//g;
22672ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($SystemRoot) {
22673ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SystemRoot = get_abs_path($SystemRoot);
22674ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22675ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22676ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    $Data::Dumper::Sortkeys = 1;
22677989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
2267862ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    if($SortDump)
2267962ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    {
2268062ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Useperl = 1;
2268162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko        $Data::Dumper::Sortkeys = \&dump_sorting;
2268262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko    }
22683989a50b439471cef748a07e7824021c836ab2c9eAndrey Ponomarenko
22684ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetLibsPath)
22685ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22686ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetLibsPath) {
22687ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetLibsPath\'");
22688ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22689ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Lib (split(/\s*\n\s*/, readFile($TargetLibsPath))) {
22690ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetLibs{$Lib} = 1;
22691ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22692ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22693ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeadersPath)
22694ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --headers-list
22695ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $TargetHeadersPath) {
22696ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$TargetHeadersPath\'");
22697ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22698ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Header (split(/\s*\n\s*/, readFile($TargetHeadersPath)))
22699ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22700ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetHeaders{1}{$Header} = 1;
22701ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $TargetHeaders{2}{$Header} = 1;
22702ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22703ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22704ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TargetHeader)
22705ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --header
22706ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetHeaders{1}{$TargetHeader} = 1;
22707ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetHeaders{2}{$TargetHeader} = 1;
22708ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22709ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($TestTool
22710ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    or $TestDump)
22711ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --test, --test-dump
22712ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to compile libs
22713ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("RegTests");
22714f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        testTool($TestDump, $Debug, $Quiet, $ExtendedCheck, $LogMode, $ReportFormat, $DumpFormat,
22715f48ec93de57523ec5eef23a60d3b50c71c106983Andrey Ponomarenko        $LIB_EXT, $GCC_PATH, $Browse, $OpenReport, $SortDump, $CheckHeadersOnly, $CheckObjectsOnly);
22716ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22717ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22718ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpSystem)
22719ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-system
22720ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
227219927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        if($DumpSystem=~/\.(xml|desc)\Z/)
22722ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # system XML descriptor
22723ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -f $DumpSystem) {
22724ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access file \'$DumpSystem\'");
22725ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22726ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my $Ret = readSystemDescriptor(readFile($DumpSystem));
227279927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            foreach (@{$Ret->{"Tools"}})
227289927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko            {
22729570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                push_U($SystemPaths{"bin"}, $_);
22730570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko                $TargetTools{$_} = 1;
22731ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22732ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Ret->{"CrossPrefix"}) {
22733ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                $CrossPrefix = $Ret->{"CrossPrefix"};
22734ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22735ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22736ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        elsif($SystemRoot_Opt)
22737ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # -sysroot "/" option
22738ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # default target: /usr/lib, /usr/include
22739ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # search libs: /usr/lib and /lib
22740ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/lib") {
22741ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/lib'");
22742ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22743ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/lib") {
22744ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/lib'");
22745ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22746ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if(not -e $SystemRoot."/usr/include") {
22747ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                exitStatus("Access_Error", "can't access '".$SystemRoot."/usr/include'");
22748ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22749ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            readSystemDescriptor("
22750ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <name>
22751ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $DumpSystem
22752ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </name>
22753ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <headers>
22754ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/include
22755ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </headers>
22756ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <libs>
22757ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/usr/lib
22758ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </libs>
22759ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                <search_libs>
22760ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    $SystemRoot/lib
22761ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                </search_libs>");
22762ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22763ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        else {
22764ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "-sysroot <dirpath> option should be specified, usually it's \"/\"");
22765ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22766ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin|gcc"); # to check symbols
22767ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($OStarget eq "windows")
22768ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        { # to run dumpbin.exe
22769ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko          # and undname.exe
22770ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            check_win32_env();
22771ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
227729927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        dumpSystem(getSysOpts());
22773ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22774ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22775ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CmpSystems)
22776ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --cmp-systems
22777ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        detect_default_paths("bin"); # to extract dumps
22778ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        loadModule("SysCheck");
227799927e33079b748463e883b96c4759f43f4d5de67Andrey Ponomarenko        cmpSystems($Descriptor{1}{"Path"}, $Descriptor{2}{"Path"}, getSysOpts());
22780ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22781ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22782570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    if($GenerateTemplate)
22783570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko    {
22784570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        writeFile("VERSION.xml", $DescriptorTemplate."\n");
22785570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        printMsg("INFO", "XML-descriptor template ./VERSION.xml has been generated");
22786ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit(0);
22787ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22788ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryName) {
22789570ece5f82489943ef2cc5f69013eeef5f0b87ffAndrey Ponomarenko        exitStatus("Error", "library name is not selected (-l option)");
22790ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22791ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    else
22792ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # validate library name
22793ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if($TargetLibraryName=~/[\*\/\\]/) {
22794ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Error", "\"\\\", \"\/\" and \"*\" symbols are not allowed in the library name");
22795ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22796ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22797ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if(not $TargetLibraryFName) {
22798ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        $TargetLibraryFName = $TargetLibraryName;
22799ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22800ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($CheckHeadersOnly_Opt and $CheckObjectsOnly_Opt) {
22801ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exitStatus("Error", "you can't specify both -headers-only and -objects-only options at the same time");
22802ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22803ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SymbolsListPath)
22804ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22805ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SymbolsListPath) {
22806ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SymbolsListPath\'");
22807ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22808ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SymbolsListPath))) {
22809ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList{$Interface} = 1;
22810ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22811ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22812fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    if($SkipSymbolsListPath)
22813fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    {
22814fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        if(not -f $SkipSymbolsListPath) {
22815fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipSymbolsListPath\'");
22816fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22817fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        foreach my $Interface (split(/\s*\n\s*/, readFile($SkipSymbolsListPath))) {
22818fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko            $SkipSymbolsList{$Interface} = 1;
22819fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko        }
22820fe00e7ef2a23c401d9cdfd47b1523bc9ec711ed0Andrey Ponomarenko    }
22821ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($SkipHeadersPath)
22822ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22823ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $SkipHeadersPath) {
22824ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$SkipHeadersPath\'");
22825ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22826ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Path (split(/\s*\n\s*/, readFile($SkipHeadersPath)))
228271bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        { # register for both versions
228281bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{1}{$Path} = 1;
228291bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko            $SkipHeadersList{2}{$Path} = 1;
22830ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            my ($CPath, $Type) = classifyPath($Path);
22831ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{1}{$Type}{$CPath} = 1;
22832ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SkipHeaders{2}{$Type}{$CPath} = 1;
22833ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22834ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22835ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($ParamNamesPath)
22836ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22837ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $ParamNamesPath) {
22838ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$ParamNamesPath\'");
22839ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22840ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        foreach my $Line (split(/\n/, readFile($ParamNamesPath)))
22841ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        {
22842ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            if($Line=~s/\A(\w+)\;//)
22843ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            {
22844ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                my $Interface = $1;
2284562ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                if($Line=~/;(\d+);/)
2284662ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22847ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    while($Line=~s/(\d+);(\w+)//) {
22848ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$1}=$2;
22849ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22850ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
2285162ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                else
2285262ddcfa624d1071a751d5d5d070836864c8c2508Andrey Ponomarenko                {
22853ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    my $Num = 0;
22854ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    foreach my $Name (split(/;/, $Line)) {
22855ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                        $AddIntParams{$Interface}{$Num++}=$Name;
22856ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                    }
22857ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko                }
22858ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            }
22859ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22860ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22861ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($AppPath)
22862ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    {
22863ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        if(not -f $AppPath) {
22864ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            exitStatus("Access_Error", "can't access file \'$AppPath\'");
22865ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
228661693447e958e56734a9d3291c320b0ff3c4c6d47Andrey Ponomarenko        foreach my $Interface (readSymbols_App($AppPath)) {
22867ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko            $SymbolsList_App{$Interface} = 1;
22868ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        }
22869ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22870ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    if($DumpAPI)
22871ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    { # --dump-abi
22872ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko      # make an API dump
22873ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        create_ABI_Dump();
22874ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko        exit($COMPILE_ERRORS);
22875ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    }
22876ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    # default: compare APIs
22877ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d1 <path>
22878ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    #  -d2 <path>
228791bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    compareInit();
228801bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    if($JoinReport or $DoubleReport)
228811bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    {
228821bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
228831bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
228841bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
228851bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($BinaryOnly) {
228861bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Binary");
228871bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
228881bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    elsif($SourceOnly) {
228891bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko        compareAPIs("Source");
228901bdef348cda66f0ff6a53fb14dc12c3fab146f75Andrey Ponomarenko    }
22891ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko    exitReport();
22892ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko}
22893ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenko
22894ab282100b2bf768a25be2a27675cd98e4e20f1d7Andrey Ponomarenkoscenario();
22895